Questions tagged [jenkins-pipeline]

Questions about the Jenkins “Pipeline” plugin suite (formerly “Workflow”). Not about pipelines in Jenkins in general (e.g. using downstream jobs).

The Pipeline (formerly known as Workflow) plugin suite makes it possible to handle several build/test/deploy steps in a centralized manner, while integrating with Jenkins features like slaves and publishers.

More Info

Alternative Pipeline Plugins

The following plugins allow the implementation of pipelines in Jenkins, without the Pipeline plugins suite.

12587 questions
889
votes
17 answers

Error "The input device is not a TTY"

I am running the following command from my Jenkinsfile. However, I get the error "The input device is not a TTY". docker run -v $PWD:/foobar -it cloudfoundry/cflinuxfs2 /foobar/script.sh Is there a way to run the script from the Jenkinsfile without…
Anthony
  • 33,838
  • 42
  • 169
  • 278
510
votes
41 answers

Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

I am new to docker. I just tried to use docker in my local machine(Ubuntu 16.04) with Jenkins. I configured a new job with below pipeline script. node { stage('Build') { docker.image('maven:3.3.3').inside { sh 'mvn --version' …
Ponsuyambu
  • 7,876
  • 5
  • 27
  • 41
357
votes
10 answers

How do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?

I have something like this on a Jenkinsfile (Groovy) and I want to record the stdout and the exit code in a variable in order to use the information later. sh "ls -l" How can I do this, especially as it seems that you cannot really run any kind of…
sorin
  • 161,544
  • 178
  • 535
  • 806
302
votes
16 answers

How can I test a change made to Jenkinsfile locally?

When writing jenkins pipelines it seems to be very inconvenient to commit each new change in order to see if it works. Is there a way to execute these locally without committing the code?
sorin
  • 161,544
  • 178
  • 535
  • 806
247
votes
4 answers

Jenkins: Can comments be added to a Jenkinsfile?

Are comments possible in a Jenkinsfile? If so, what's the syntax? I am using the declarative pipeline syntax. I want to comment out the "post" section below until my SMTP server is working. pipeline { agent { label 'docker-build-slave' } …
danday74
  • 52,471
  • 49
  • 232
  • 283
217
votes
5 answers

How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?

How can I trigger build of another job from inside the Jenkinsfile? I assume that this job is another repository under the same github organization, one that already has its own Jenkins file. I also want to do this only if the branch name is…
sorin
  • 161,544
  • 178
  • 535
  • 806
194
votes
1 answer

Jenkins pipeline: agent vs node?

What is the difference between an agent and a node in a jenkins pipeline? I've found those definitions: Node: A Pipeline performs most of the work in the context of one or more declared node steps. Agent: The agent directive specifies where the…
Matthias M
  • 12,906
  • 17
  • 87
  • 116
187
votes
15 answers

Jenkins Pipeline Wipe Out Workspace

We are running Jenkins 2.x and love the new Pipeline plugin. However, with so many branches in a repository, disk space fills up quickly. Is there any plugin that's compatible with Pipeline that I can wipe out the workspace on a successful build?…
155
votes
5 answers

Conditional step/stage in Jenkins pipeline

How do you run a build step/stage only if building a specific branch? For example, run a deployment step only if the branch is called deployment, leaving everything else the same.
Devonte
  • 3,319
  • 5
  • 20
  • 15
154
votes
8 answers

Jenkins CI Pipeline Scripts not permitted to use method groovy.lang.GroovyObject

I am Using Jenkins 2 for compiling Java Projects, I want to read the version from a pom.xml, I was following this example: https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md The example suggest: It seems that there is some…
Daniel Hernández
  • 4,078
  • 6
  • 27
  • 38
154
votes
20 answers

How to list all `env` properties within jenkins pipeline job?

Given a jenkins build pipeline, jenkins injects a variable env into the node{}. Variable env holds environment variables and values. I want to print all env properties within the jenkins pipeline. However, I do no not know all env properties ahead…
JamesThomasMoon
  • 6,169
  • 7
  • 37
  • 63
147
votes
6 answers

Checkout Jenkins Pipeline Git SCM with credentials?

I was following this tutorial: node { git url: 'https://github.com/joe_user/simple-maven-project-with-tests.git' ... } However it doesn't tell how to add credentials. Jenkins does have specific "Credentials" section where you define user…
Render
  • 2,199
  • 2
  • 16
  • 14
140
votes
7 answers

Cannot define variable in pipeline stage

I'm trying to create a declarative Jenkins pipeline script but having issues with simple variable declaration. Here is my script: pipeline { agent none stages { stage("first") { def foo = "foo" // fails with "WorkflowScript:…
Malcolm Crum
  • 4,345
  • 4
  • 30
  • 49
137
votes
3 answers

Jenkins pipeline how to change to another folder

Currently i am using Jenkins pipeline script. For running one command, I need to access a folder outside its workspace directory. I tried sh "cd $workspace/", but it returned current workspace folder. How I can change to root workspace directory…
wanderors
  • 2,030
  • 5
  • 21
  • 35
130
votes
4 answers

How to add a timeout step to Jenkins Pipeline

When you are using a free style project you can set that after 20 minutes the build is aborted if not concluded. How is this possible with a Jenkins Multi Branch Pipeline Project?
Devonte
  • 3,319
  • 5
  • 20
  • 15
1
2 3
99 100