jenkins-workflow

Show a Jenkins pipeline stage as failed without failing the whole job

对着背影说爱祢 提交于 2019-11-27 12:01:37
Here's the code I'm playing with node { stage 'build' echo 'build' stage 'tests' echo 'tests' stage 'end-to-end-tests' def e2e = build job:'end-to-end-tests', propagate: false result = e2e.result if (result.equals("SUCCESS")) { stage 'deploy' build 'deploy' } else { ?????? I want to just fail this stage } } Is there any way for me to mark the 'end-to-end-tests' stage as failed without failing the whole job? Propagate false just always marks the stage as true, which is not what I want, but Propagate true marks the job as failed which I also don't want. Stage takes a block now, so wrap the stage

Jenkins Build Pipeline - Restart At Stage

早过忘川 提交于 2019-11-27 11:48:38
I have the following build pipeline set up as a job: Stage 1 - verify all dependencies exist Stage 2 - build the new jar Stage 3 - Run integration tests Stage 4 - Deploy to staging environment (manual step) Stage 5 - Deploy to production environment (manual step) I am looking for a way to start the build pipeline from a particular stage in case of a transient failure. For example, let's say there was a network issue when the user clicked to deploy to production. I don't think it makes sense to start the pipeline from stage 1... I'd like to try that step again and continue on from there in the

Jenkins: Trigger Multi-branch pipeline on upstream change

依然范特西╮ 提交于 2019-11-27 10:20:59
问题 I am currently testing the pipeline approach of Jenkins 2.0 to see if it works for the build environment I am using. First about the environment itself. It currently consists of multiple SCM repositories. Each repository contains multiple branches, for the different stages of the development and each branch is build with multiple configurations. Not all configurations apply to every repository. Currently every repository/branch is setup as a Matrix Project for the different configurations.

How do I use Jenkins Pipeline properties step?

雨燕双飞 提交于 2019-11-27 04:26:24
问题 I am studying capabilities of Jenkins Pipeline:Multibranch. It is said that a recently introduced properties step might be useful there, but I can't catch how it works and what is its purpose. Its hint message doesn't seem to be very clear: Updates the properties of the job which runs this step. Mainly useful from multibranch workflows, so that Jenkinsfile itself can encode what would otherwise be static job configuration. So I created a new Pipeline with this as a script (pasted directly

how to get $CAUSE in workflow

此生再无相见时 提交于 2019-11-27 03:47:29
问题 Jenkins has a $CAUSE variable available to freestyle build jobs. How can I access this or something similar in workflow? My team makes use of it in email output of existing ad-hoc builds. We'd like to continue the same in new workflow based jobs. 回答1: It looks like Workflow builds don't have this variable injected. However you can retrieve the required info from currentBuild.rawBuild object using hudson.model.Run.getCause() or hudson.model.Run.getCauses() method. Example: Workflow script:

Jenkins Workflow Checkout Accessing BRANCH_NAME and GIT_COMMIT

江枫思渺然 提交于 2019-11-27 02:16:58
问题 I cannot seem to extract $GIT_COMMIT and $BRANCH_NAME from a Jenkins Workflow Checkout step. I would like to be able to send this information through to my Gradle scripts in order to pass it onto external sources such as Static analysis etc. Currently I try to run this: checkout([$class: 'GitSCM', branches: [[name: '*/master']], userRemoteConfigs: [[credentialsId: '2b74a351-67d5-4d00-abd3-49842a984201', url: 'ssh://git@corporate.com:repo.git']]]) And I would like to achieve the following or

Checkout SVN with credentials in Jenkins pipeline?

 ̄綄美尐妖づ 提交于 2019-11-27 01:59:07
问题 How can I check out a Subversion repository that requires user credentials, via a Jenkins pipeline groovy script? It appears that the built-in svn command doesn't support credentials, so I tried code like this: node { stage 'checkout' withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: '34761a89-1402-47d7-96e2-aec22ffdc50b', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { sh "svn co https://trac.nci.org.au/svn/cable/branches/$SVN_BRANCH --username

How to implement Post-Build stage using Jenkins Pipeline plug-in?

泪湿孤枕 提交于 2019-11-27 00:50:48
问题 After reading Jenkins tutorial explaining Pipeline plug-in, it seems that plug-in should make it possible to implement Post-Build steps. However documentation is rather limited in regard to specific instructions. For example I wonder how to implement: Run only if build succeeds Run only if build succeeds or is unstable Run regardless of build result Run only if build succeeds stage 'build' ... build ... tests stage 'post-build' ... (Or add -Dmaven.test.failure.ignore=false to the MAVEN_OPTS )

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

落花浮王杯 提交于 2019-11-26 21:23:34
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 groovy code inside the Jenkinsfile ? G. Roggemans The latest version of the pipeline sh step allows you to do the following; // Git committer email GIT_COMMIT_EMAIL = sh ( script: 'git --no-pager show -s --format=\'%ae\'', returnStdout: true ).trim() echo "Git committer email: ${GIT_COMMIT_EMAIL}" Another feature is the returnStatus option. // Test

Is it possible to capture the stdout from the sh DSL command in the pipeline

↘锁芯ラ 提交于 2019-11-26 18:48:40
For example: var output=sh "echo foo"; echo "output=$output"; I will get: output=0 So, apparently I get the exit code rather than the stdout. Is it possible to capture the stdout into a pipeline variable, such that I could get: output=foo as my result? Andrey Prokopiev Note: The linked Jenkins issue has since been solved. As mention in JENKINS-26133 it was not possible to get shell output as a variable. As a workaround suggested using of writ-read from temporary file. So, your example would have looked like: sh "echo foo > result"; def output=readFile('result').trim() echo "output=$output";