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.

10245 questions
578
votes
13 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
  • 27,490
  • 32
  • 129
  • 238
273
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
  • 137,198
  • 150
  • 472
  • 707
264
votes
31 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
  • 4,730
  • 2
  • 20
  • 35
244
votes
14 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
  • 137,198
  • 150
  • 472
  • 707
210
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
  • 38,089
  • 29
  • 169
  • 214
166
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
  • 137,198
  • 150
  • 472
  • 707
165
votes
14 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?…
qmo
  • 2,828
  • 3
  • 15
  • 23
152
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
  • 8,008
  • 11
  • 67
  • 83
123
votes
6 answers

Jenkins: 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
  • 3,425
  • 3
  • 24
  • 38
121
votes
17 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. For example, environment variable BRANCH_NAME can be accessed with node { echo ${env.BRANCH_NAME} ... I…
JamesThomasMoon
  • 3,565
  • 4
  • 29
  • 37
119
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
  • 1,829
  • 2
  • 14
  • 13
119
votes
4 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…
110
votes
3 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
  • 2,449
  • 5
  • 15
  • 13
106
votes
5 answers

Configuring Groovy SDK within IntelliJ IDEA

I am running IntelliJ IDEA 2017.2.3. I installed Groovy 2.4.12 via Homebrew (OS X). When I open a Groovy source file (or a Jenkinsfile), I get the following: Groovy SDK is not configured for module 'my-module' . . . . . Configure Groovy…
Carl Patenaude Poulin
  • 4,468
  • 4
  • 17
  • 36
106
votes
7 answers

Jenkins scripted pipeline or declarative pipeline

I'm trying to convert my old style project base workflow to a pipeline based on Jenkins. While going through docs I found there are two different syntaxes named scripted and declarative. Such as the Jenkins web declarative syntax release recently…
Nayana Adassuriya
  • 19,806
  • 20
  • 87
  • 131
1
2 3
99 100