jenkins-workflow

Get absolute path to workspace directory in Jenkins Pipeline plugin

前提是你 提交于 2019-11-26 17:09:17
问题 I'm currently doing some evaluation on the Jenkins Pipeline plugin (formerly know as Workflow plugin). Reading the documentation I found out that I currently cannot retriev the workspace path using env.WORKSPACE : The following variables are currently unavailable inside a workflow script: NODE_LABELS WORKSPACE SCM-specific variables such as SVN_REVISION Is there any other way how to get the absolute path to the current workspace? I need this running some test which in turn gets some parameter

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

时光总嘲笑我的痴心妄想 提交于 2019-11-26 15:44:43
问题 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

How do I prevent two pipeline jenkins jobs of the same type to run in parallel on the same node?

不想你离开。 提交于 2019-11-26 15:44:27
问题 I want not to allow two jobs of the same type (same repository) not to run in parallel on the same node. How can I do this using groovy inside Jenkinsfile? 回答1: The answer provided in https://stackoverflow.com/a/43963315/6839445 is deprecated. The current method to disable concurrent builds is to set options: options { disableConcurrentBuilds() } Detailed description is available here: https://jenkins.io/doc/book/pipeline/syntax/#options 回答2: You got at the disableConcurrentBuilds property:

How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?

限于喜欢 提交于 2019-11-26 15:08:29
问题 How can I trigger build of another job from inside the Jenkinsfile ? I assume that this job is another repository under the same github organization, one that already has its own Jenkins file. I also want to do this only if the branch name is master, as it doesn't make sense to trigger downstream builds of any local branches. Update: stage 'test-downstream' node { def job = build job: 'some-downtream-job-name' } Still, when executed I get an error No parameterized job named some-downtream-job

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

南楼画角 提交于 2019-11-26 08:10:11
问题 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? 回答1: 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