jenkins-declarative-pipeline

How would I store all failed stages of my declarative Jenkins pipeline

断了今生、忘了曾经 提交于 2020-07-10 01:47:06
问题 In my Jenkins pipeline, I have 15 stages. Now I have a post function at the end of the Jenkins file to send me an email about whether the whole process is failed or success. I would like to include all the stages that are failed in the email too. Using post in each stage is not a good idea, because I would receive 15 emails each time the job runs. I am thinking of creating a list and save all failed env.STAGE_NAME in the list and print it at the end? But it would not allow me to do such a

Jenkins Agent Cannot run program “docker”: error=2, No such file or directory

浪尽此生 提交于 2020-06-17 15:03:33
问题 I have a strange behaviour with my jenkins agent. i have a master and a seperate build agent, which has access to docker. while i'm running the following pipeline script on the build agent: node { sh "id" sh "echo $PATH" sh "docker ps" docker.image("node:latest").inside("") { sh "npm --version" } } i get the following output: Running on docker-agent in /home/jenkins/workspace/test [Pipeline] { [Pipeline] sh [test] Running shell script + id uid=1000(jenkins) gid=1000(jenkins) groups=900(docker

Jenkins Declarative pipeline get build failure cause

微笑、不失礼 提交于 2020-05-17 05:51:30
问题 I recently converted a scripted pipeline into a declarative pipeline but having trouble to get the build failure case in the post section. For a scripted pipeline, I can easily wrap the pipeline inside a try-catch and have access to the exception object. But not for declarative pipeline like this: pipeline { stages { ... } post{ failure { script { //this is where i need the failure exception detail handleFailure() } } } } Im not sure how to do that, I'm trying getContext() method but it

Jenkins Declarative pipeline get build failure cause

耗尽温柔 提交于 2020-05-17 05:51:10
问题 I recently converted a scripted pipeline into a declarative pipeline but having trouble to get the build failure case in the post section. For a scripted pipeline, I can easily wrap the pipeline inside a try-catch and have access to the exception object. But not for declarative pipeline like this: pipeline { stages { ... } post{ failure { script { //this is where i need the failure exception detail handleFailure() } } } } Im not sure how to do that, I'm trying getContext() method but it

Declarative Pipeline with dynamic matrix axis values

前提是你 提交于 2020-04-11 06:17:43
问题 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 parameters. One of this parameters is the axis-values. The Problem I have is pretty similar to this reddist post. I want to set the "values" of the "axis" of the matrix-build from a variable. I am out of Ideas, is this even possible? So here is my

invoke one Jenkinsfile of different repo to another jenkinsfile

那年仲夏 提交于 2019-12-25 03:35:32
问题 I have a Jenkinsfile-A like below, In this file,I need to invoke another Jenkinsfile-B after execution of all the stages. Jenkinsfile-A #!groovy​ pipeline { agent { label "" } triggers { pollSCM('*/5 * * * *') } stages { stage('Build Artifact') { steps { } } stage('Publish Artifact') { steps { } } }//stages post { always { deleteDir() /* clean up our workspace */ } } }//pipeline def jenkinsFile stage('Loading Jenkinsfile'){ jenkinsFile = fileLoader.fromGit('Jenkinsfile', 'git@bitbucket.org

How to select multiple JDK version in declarative pipeline Jenkins

。_饼干妹妹 提交于 2019-12-21 01:44:30
问题 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 { agent any tools { jdk 'jdk_1.8.0_151' jdk 'jdk_1.6.0_45' } stages { stage('java 8') { steps { sh 'java -version' sh 'javac -version' } } stage('java 6') { steps { sh 'java -version' sh 'javac -version' } } } } 回答1: you can add a tools section for

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

我是研究僧i 提交于 2019-12-20 10:01:12
问题 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 { agent any stages { stage('stage 1') { steps { echo "I need to run every time" } } stage('stage 2') { steps { echo "I need to run every time, even if stage 1 fails" } } stage('stage 3') { steps { echo "Bonus points if the solution is robust enough to

Value returned from a script does not assigned to a variable declared in jenkins declarative pipeline stage

被刻印的时光 ゝ 提交于 2019-12-13 07:48:19
问题 I am working on adding a jenkins Declarative pipeline for automation testing. In the test run stage i want to extract the failed tests from the log. i am using a groovy function for extracting the test result. this function is not a part of the jenkins pipeline. It is another script file. The function works fine and it build a string containing the failure details. Inside a pipeline stage i am calling this function and assinging the returned string to another variable. But when i echo the

Jenkins declarative pipeline 1.3 run parallel for all jobs

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:13:39
问题 I have setup a pipeline project similar to https://jenkins.io/doc/book/pipeline/syntax/#parallel-stages-example and it works fine. But I have created the same project for different jobs, so rather than creating new jobs can I run for loop for all jobs e.g. jobs = [job1, job2, job3] and run above pipeline code for different jobs. Something similar to https://jenkins.io/doc/book/pipeline/syntax/#script-example Can I use a for loop or similar logic to run a declarative pipeline? I found similar