jenkins-workflow

Access Stage results in Workflow/ Pipeline plugin

徘徊边缘 提交于 2019-12-21 01:56:41
问题 I have a pipeline with different stages. I want the current job to check how many stages have passed in the previous build and log it in the console? Consider this is my current pipeline node(){ stage "1" do something stage "2" do something else } I want a groovy script to give my something like this println currentBuild.previousBuild.getStage("1").result The purpose of my code is track successes & failures in different stages across my builds. Are there any alternatives to this approach? 回答1

How to use a parameter from NodeLabelParameter Plugin with the “build” step of Jenkins Workflow

◇◆丶佛笑我妖孽 提交于 2019-12-19 19:58:06
问题 I have a job that take a "Node" parameter provided by the NodeLabelParameter plugin, and I would like to call it from a jenkins "Workflow" job, via the "build" step. When I use the Snippet Generator with "Build a job", the generated code is : build job: 'test job', parameters: [<object of type org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterValue>] Of course this is not valid. I tried this (I found this constructor in the NodeLabelParameter plugin code): build job: 'test job',

How to get SVN revision number in Jenkins Workflow Plugin?

痞子三分冷 提交于 2019-12-19 11:36:10
问题 I'm using Jenkins 1.596, Workflow 1.3, and Svn plugin 2.5. I'm trying to get the svn revision number in my workflow script. The section of my workflow script is: node { checkout scm: [ $class: "SubversionSCM", locations: [[ remote:'https://secure3.svnrepository.com/somerepo/trunk', credentialsId: cid]] ] stage 'build' dir('trunk') { def revision = 'svn info'.execute().in.text.split('\n').find { it.startsWith('Revision') }.split(':')[1].trim() println revision def svnHome = tool 'Svn' sh "

Jenkins Workflow Build Information

旧街凉风 提交于 2019-12-18 14:52:11
问题 How do you access current, and related, build information from within a Jenkins workflow groovy script? I can see things like currentBuild.result and currentBuild.previousBuild being documented, but I can't see how I can access, for example: The URL of the current build job. The URL of build jobs that this workflow triggered. The console output of a particular failed build job, etc. Thanks for any pointers. 回答1: currentBuild.rawBuild will give you the non cached hudson.model.Run object, see

Accessing SCM (Git) variables on a Jenkins Pipeline job [duplicate]

删除回忆录丶 提交于 2019-12-18 12:47:37
问题 This question already has answers here : Git Variables in Jenkins Workflow plugin (7 answers) Closed 3 years ago . Here's my pipeline code: node ('master') { git url: "$GIT_REPO_URL", branch: "$GIT_BRANCH" echo env.GIT_COMMIT echo env.GIT_BRANCH echo env.GIT_REVISION } The build results looks like: Started by user anonymous [Pipeline] Allocate node : Start Running on master in /var/lib/jenkins/jobs/test/workspace [Pipeline] node { [Pipeline] git > git rev-parse --is-inside-work-tree # timeout

How do I tag the current git changeset from inside the Jenkinsfile?

浪尽此生 提交于 2019-12-18 12:28:34
问题 I want to tag the current git changeset and push the tag from inside the Jenkinsfile. If the tag already exists it must be replaced. I want to use this logic in order to tag the build that passed with the snapshot tag, which would be a mobile tag. How can I do this? 回答1: Here is the way I was able to implement this this way, but if you know a better way I am more than willing to hear it. #!groovy stage 'build' node { repositoryCommiterEmail = 'ci@example.com' repositoryCommiterUsername =

Run Parts of a Pipeline as Separate Job

我的梦境 提交于 2019-12-18 11:33:03
问题 We're considering using the Jenkins Pipeline plugin for a rather complex project consisting of several deliveries that need to be build using different tools (on different machines) before being merged. Still, it seems to be easy enough to do a complete build with a single Jenkinsfile , and I like the automatic discovery of git branches that comes with Pipeline. However, at this point, we have jobs for each of the deliveries and use a build-flow based "meta" job to orchestrate the individual

Jenkins Build Periodically - Schedule

眉间皱痕 提交于 2019-12-18 05:53:39
问题 I am looking to build periodically every 15 minutes. I have looked online and I am using this schedule: */15 * * * * Jenkins is telling me to spread load evenly by using H/15 * * * * rather than */15 * * * * Could someone tell me the difference between using H instead of * ? 回答1: Yes. From the Build Triggers → Build periodically → Schedule → inline help: To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For

How to get the git latest commit message and prevent the jenkins build if the commit message contains [ci skip]?

若如初见. 提交于 2019-12-17 18:34:54
问题 I tried to get the git commit message in jenkinsfile and prevent the build based on commit message. env.GIT_COMMIT doesn't return the commit details in jenkinsfile. How to get the git latest commit message and prevent the jenkins build if the commit message contains [ci skip] in it? 回答1: The build will pass when [ci skip] is provided in the last git log, but will not run the actual build code (the replacement to the first echo statement) node { checkout scm result = sh (script: "git log -1 |

How can I use the Jenkins Copy Artifacts Plugin from within the pipelines (jenkinsfile)?

柔情痞子 提交于 2019-12-17 16:27:17
问题 I am trying to find an example of using the Jenkins Copy Artifacts Plugin from within Jenkins pipelines (workflows). Can anyone point to a sample Groovy code that is using it? 回答1: If builds are not running in the same pipeline you can use direct CopyArtifact plugin, here is example: https://www.cloudbees.com/blog/copying-artifacts-between-builds-jenkins-workflow and example code: node { // setup env.. // copy the deployment unit from another Job... step ([$class: 'CopyArtifact', projectName: