Questions tagged [jenkins-declarative-pipeline]

A plugin tool for Jenkins which presents a simplified and opinionated syntax on top of the Pipeline sub-systems.

483 questions
94
votes
4 answers

How to create methods in Jenkins Declarative pipeline?

In Jenkins scripted pipeline we are able to create methods and can call them. Is it possible also in the Jenkins declarative pipeline? And how?
46
votes
8 answers

In a declarative jenkins pipeline - can I set the agent label dynamically?

Is there a way to set the agent label dynamically and not as plain string? The job has 2 stages: First stage - Runs on a "master" agent, always. At the end of this stage I will know on which agent should the 2nd stage run. Second stage - should run…
Gilad Shahrabani
  • 706
  • 1
  • 6
  • 12
29
votes
4 answers

How to continue past a failing stage in Jenkins declarative pipeline syntax

I want to define multiple stages in Jenkins declarative pipeline syntax which can continue past any one of them failing. I cannot find any existing questions which are true duplicates, because they all assume or allow scripted syntax. pipeline { …
dolphy
  • 6,218
  • 4
  • 24
  • 32
24
votes
3 answers

How to use ${currentBuild.result} to indicate "SUCCESS" not "null"

My Jenkins declarative pipeline has the following post action: mail to: '', subject: "Status of pipeline: ${currentBuild.fullDisplayName}", body: "${env.BUILD_URL} has result ${currentBuild.result}" When the build succeeds the…
DavidA
  • 2,053
  • 6
  • 30
  • 54
22
votes
1 answer

Declarative Pipeline - Use of when condition, how to do nested conditions anyOf/allOf/not

I am stuck at how to properly use nested conditions as proposed in the Jenkins syntax. https://jenkins.io/doc/book/pipeline/syntax/#when This is my current stage: stage('Build'){ when{ anyOf{ allOf{ expression{env.BRANCH_NAME…
Tai Ly
  • 341
  • 1
  • 2
  • 10
21
votes
3 answers

How to select multiple JDK version in declarative pipeline Jenkins

I want to use different JDK versions for different stages in Jenkins declarative pipeline. In the first stage I am using Java 8. In the second stage i am using Java 6. How to select multiple JDK version in declarative pipeline in Jenkins? pipeline…
YourAboutMeIsBlank
  • 1,787
  • 3
  • 18
  • 27
20
votes
1 answer

Jenkins Declarative Pipelines: How to rename "Declarative: Post Actions" step?

I have a declarative pipeline which looks like this: pipeline { stages {...} post { success {...} failure {...} } } It leads to creation of a last step called "Declarative: Post Actions". Q: How to rename the…
Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148
15
votes
1 answer

Declarative Pipeline with dynamic matrix axis values

Hi I am trying to get a Jenknis-Declarative-Pipeline-Job work. The Use-Case should be pretty simple: I want to build multiple Plugins with the same Jenkins-pipeline. To do so I wrote a "JenkinsLibrary" with an interface the Plugins can use for…
14
votes
4 answers

How to define workspace volume for jenkins pipeline declarative

I am trying to setup declarative pipeline where I would like to persiste workspace as volume claim so large git checkout can be faster. Based on doc there are options workspaceVolume and persistentVolumeClaimWorkspaceVolume but I am not able to make…
12
votes
3 answers

How can I parameterize Jenkinsfile jobs

I have Jenkins Pipeline jobs, where the only difference between the jobs is a parameter, a single "name" value, I could even use the multibranch job name (though not what it's passing as JOB_NAME which is the BRANCH name, sadly none of the envs look…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
11
votes
1 answer

Clean way to exit declarative Jenkins pipeline as success?

I am looking for the cleanest way to exit a declarative Jenkins pipeline, with a success status. While exiting with an error is very neat using error step , I couldn't find any equal way to exit with success code. E.G: stage('Should Continue?') { …
BarakD
  • 538
  • 8
  • 18
11
votes
1 answer

How to use Jenkins declarative pipeline to build and test on multiple platforms

I'm trying to do something that I feel should be simple to do, but I can't figure out how. Basically I have a Jenkins master (running on Linux) and two slaves, one on Windows and the other on macOS. I want to build my project on all 3 platforms and…
10
votes
4 answers

Jenkins: Connect to a Docker container from a stage that is run with an agent (another Docker container)

I am in the process of reworking a pipeline to use Declarative Pipelines approach so that I will be able to use Docker images on each stage. At the moment I have the following working code which performs integration tests connecting to a DB which is…
Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148
10
votes
1 answer

Manual Build Step in Jenkins Declarative Pipeline?

This is a follow-up question to this previous post that doesn't seem like it was ever truly answered with more than a "this looks promising": Jenkins how to create pipeline manual step. This is a major functionality gap for CICD pipelines. The…
10
votes
2 answers

Dynamically defining parallel steps in declarative jenkins pipeline

I try to parallelize dynamically defined set of functions as follows: def somefunc() { echo 'echo1' } def somefunc2() { echo 'echo2' } running_set = [ { somefunc() }, { somefunc2() } ] pipeline { agent none stages{ …
pbn
  • 2,406
  • 2
  • 26
  • 39
1
2 3
32 33