Questions tagged [jenkins-pipeline]

For questions specifically about Jenkins 2.0's pipeline architecture. This includes both declarative and scripted pipelines.

264 questions
111
votes
7 answers

Cleanest way to prematurely exit a Jenkins Pipeline job as a success?

I have a job that will create files, unless one of the values being fed to it matches an older value. What's the cleanest way in Jenkins to abort or exit the job, without it being FAILED? It exiting is the correct behavior so I want the build marked…
Alex
  • 4,612
  • 6
  • 29
  • 49
29
votes
3 answers

How to build a complex parallel Jenkins pipeline?

I've been interested in converting our bespoke Jenkins integrations into a pipeline. However, I can't seem to figure out how to do it. Can anyone help me with the Jenkins script that could do the following? 1---2---3-----------9---10 | …
29
votes
2 answers

How to define variable in Jenkins declarative pipeline?

I defined variable in 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…
Jay
  • 1,064
  • 2
  • 12
  • 21
24
votes
3 answers

Running a background process in Pipeline job

I am looking for a way to run a java process in background using Jenkins declarative pipeline. Below is the snippet of code stage('Deploy'){ steps{ script{ withEnv(['BUILD_ID=dontkill']) { sh…
Dharanidhar
  • 701
  • 2
  • 5
  • 10
21
votes
3 answers

How to disable some branches in Multibranch Jenkins Builds?

I have a multibranch job set to run any branch with a Jenkinsfile. I have some options I can think of if I want to remove a branch from the list of jobs running for the multi-branch pipeline. I can delete the branch I can delete the Jenkinsfile in…
David West
  • 1,533
  • 3
  • 18
  • 25
19
votes
1 answer

What is the difference between Jenkin's `Replay` and `Rebuild` options?

If you want to re-run a Jenkins job, you can click the Rebuild button which sometimes appears as the Replay button. What is the difference Rebuilding a job versus Replaying it? Why is it that some jobs display Replay while others display Rebuild?
Wimateeka
  • 398
  • 1
  • 2
  • 9
17
votes
2 answers

Triggering specific pipeline builds for monorepos in Jenkins

I'm in the process of converting multiple repositories into a single repository, our CI tool of choice is Jenkins due to the conversion of multiple repository structures into a single one 2 main issues have arisen. Build/test times have increased…
YellowPillow
  • 273
  • 1
  • 2
  • 5
17
votes
4 answers

Jenkins: Permission issue using Docker as build environment

I installed Jenkins on an Ubuntu 16.04 machine. The Jenkins itself is not run in a container. What I want to do is simply call yarn install using a node image. So here is my Jenkinsfile: pipeline { agent any stages { stage('install…
Michael
  • 271
  • 1
  • 2
  • 5
16
votes
3 answers

One Jenkinsfile or multiple?

So I have a Jenkinsfile defining a build pipeline and then a Jenkins job (not pipeline) with a very simple deployment script for our Docker stacks. Seeing that Jenkinsfiles can become as complex and powerful as one's coding skills are (seeing that…
Worp
  • 689
  • 4
  • 11
  • 19
14
votes
2 answers

Get all change logs of since last successful build in Jenkins Pipeline

In my Jenkins pipeline, I can get change logs of the current build by this. def changeLogSets = currentBuild.changeSets Is there a way to get all change-logs since last successful build?
Bee
  • 243
  • 1
  • 2
  • 5
14
votes
3 answers

Using Artifactory plugin in Jenkins declarative pipeline

I am using Jenkins Declarative Pipeline to automate my build process. We want to publish our artifacts to a remote JFrog repository only if certain conditions (Sonar,Checkmarx) pass. After a bit of research, I found that Artifactory plugin is…
Dharanidhar
  • 701
  • 2
  • 5
  • 10
11
votes
1 answer

Jenkins Pipeline job; proper quoting for slackSend step

This is probably 100% user error, but I can't get a pipeline job to use a variable as the channel name in a slackSend step. This uses both the Slack plugin and the Build User Vars Plugin. I'm trying to use BUILD_USER_FIRST_NAME to identify which…
Alex
  • 4,612
  • 6
  • 29
  • 49
10
votes
3 answers

Is there a way to run the Jenkinsfile from command line?

I don't want to use Jenkins UI, instead I would like to use the command line, from command line I want to execute Jenkinsfile to the Jenkins server. Is this possible? Let's say I have a Jenkinsfile, If I run the Jenkinsfile, It shoud execute the…
10
votes
1 answer

How do I trigger scripts on a merge or when a branch is deleted?

I am using jenkins multibranch pipelines. If a branch is merged and deleted jenkins removes the branch from the pipeline as well. This is great, but I want to run a command/script when a branch is removed, how can I have jenkins run a command when…
red888
  • 243
  • 3
  • 10
9
votes
1 answer

Force Jenkins to reschedule parallel pipeline step as soon as node goes offline

Exactly this. In our environment, we're using GCE preemptible nodes and the Jenkins GCE plugin. As a consequence of this, it's highly likely (even expected) that a node will go away during the course of a build. The problem is, the Jenkins GCE…
1
2 3
17 18