jenkins-pipeline
Jenkins pipeline sh fail with “cannot run program nohup” on windows
From a very quick search, it looks like your error is related to the following issue : JENKINS-33708 The main cause looks like the sh step is not supported on the Windows. You may use bat or install Cygwin for instance. Nevertheless two solutions were proposed in the previous link, suggesting you to do the … Read more
How to access parameters in a Parameterized Build?
I think the variable is available directly, rather than through env, when using Workflow plugin. Try: node() { print “DEBUG: parameter foo = ${foo}” }
Show a Jenkins pipeline stage as failed without failing the whole job
This is now possible, even with declarative pipelines: pipeline { agent any stages { stage(‘1’) { steps { sh ‘exit 0’ } } stage(‘2’) { steps { catchError(buildResult: ‘SUCCESS’, stageResult: ‘FAILURE’) { sh “exit 1” } } } stage(‘3’) { steps { sh ‘exit 0’ } } } } In the example above, all stages … Read more
How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?
In addition to the above mentioned answers: I wanted to start a job with a simple parameter passed to a second pipeline and found the answer on http://web.archive.org/web/20160209062101/https://dzone.com/refcardz/continuous-delivery-with-jenkins-workflow So i used: stage (‘Starting ART job’) { build job: ‘RunArtInTest’, parameters: [[$class: ‘StringParameterValue’, name: ‘systemname’, value: systemname]] }
Error “The input device is not a TTY”
Remove the -it from your cli to make it non interactive and remove the TTY. If you don’t need either, e.g. running your command inside of a Jenkins or cron script, you should do this. Or you can change it to -i if you have input piped into the docker command that doesn’t come from … Read more
Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap
Use JsonSlurperClassic instead. Since Groovy 2.3 (note: Jenkins 2.7.1 uses Groovy 2.4.7) JsonSlurper returns LazyMap instead of HashMap. This makes new implementation of JsonSlurper not thread safe and not serializable. This makes it unusable outside of @NonDSL functions in pipeline DSL scripts. However you can fall-back to groovy.json.JsonSlurperClassic which supports old behavior and could be … Read more
How do you load a groovy file and execute it
If your Jenkinsfile and groovy file in one repository and Jenkinsfile is loaded from SCM you have to do: Example.Groovy def exampleMethod() { //do something } def otherExampleMethod() { //do something else } return this JenkinsFile node { def rootDir = pwd() def exampleModule = load “${rootDir}@script/Example.Groovy ” exampleModule.exampleMethod() exampleModule.otherExampleMethod() }
Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
If using jenkins The user jenkins needs to be added to the group docker: sudo usermod -a -G docker jenkins Then restart Jenkins. Otherwise If you arrive to this question of stack overflow because you receive this message from docker, but you don’t use jenkins, most probably the error is the same: your unprivileged user … Read more
Docker not found when building docker image using Docker Jenkins container pipeline
You’re missing the docker client. Install it as this in Dockerfile: RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz \ && tar xzvf docker-17.04.0-ce.tgz \ && mv docker/docker /usr/local/bin \ && rm -r docker docker-17.04.0-ce.tgz Source