0

I'm writing Jenkins job using job DSL. It looks like:

job(jobName) {
  description("This is my Jenkins job.")
  steps {
    // Executing some shell here.
  }
  scm {
    // Checking out some branch from Git.
  }
  triggers {
    bitbucketPush()
    scm ''
  }
}

It works fine, but for some reason, executing my shell script it fails with an errors:

/usr/lib/git-core/git-pull: 83: /usr/lib/git-core/git-sh-setup: sed: not found basename: write error: Broken pipe /usr/lib/git-core/git-pull: 299: /usr/lib/git-core/git-sh-setup: uname: not found

etc.

As far as I understand, the issue is with PATH variable. When I'm fixing it in Jenkins from UI (in Configure section) it works fine. (adding something like this: PATH=/usr/local/bin:/usr/bin As I'm creating a lot of job, it would great to fix this PATH during creation process in my DSL scripts.

How it may be added into my DSL?

smart
  • 1,975
  • 5
  • 26
  • 46
  • Which job DSL command do you use for executing the shell? Can you expand the part of your code in the `steps` block? – Ortomala Lokni May 07 '17 at 12:22
  • @OrtomalaLokni, I'm executing some custom script which is doing some `gitcheckout`, `git pull`, `git merge` commands, etc. – smart May 07 '17 at 12:28
  • What is the output of `out.println($PATH)` and `out.println('$PATH')` at the tie you run your seed job? – thiagowfx May 09 '17 at 19:53
  • @thiagowfx, print as string returns `$PATH`. Print with variable return an error: `ERROR: (script, line 1119) No such property: $PATH for class: javaposse.jobdsl.dsl.helpers.step.StepContext` – smart May 09 '17 at 20:41
  • So, I've decided this issue outside of Job DSL. I've added `/usr/local/bin:/usr/bin:/bin` into my `PATH` variable in my script from `steps` section. – smart May 10 '17 at 01:51

1 Answers1

-1

The problem is not related to Job DSL. Try to configure the job manually and fix all problems. Then translate you configuration to Job DSL.

In this case there is something wrong with the environment on you build agent, e.g. git is not installed properly.

daspilker
  • 8,154
  • 1
  • 35
  • 49
  • So, I've added `/usr/local/bin:/usr/bin` into `PATH` variable on UI, but how to translate this to Job DSL? – smart May 09 '17 at 06:59