jenkins-pipeline

Using nested command substitution in jenkins pipeline sh step

人走茶凉 提交于 2019-12-11 03:16:16
问题 I'm trying to flatten a results directory prior to archiving using a symbolic link to the relevant inner folder that first traverses a bunch of variable path names determined at runtime. I can't quite seem to get the syntax right with this command substitution approach I picked up from this SO answer. Question: is there a rule for how to properly escape command substitution chains from a Jenkins pipeline step that I'm unaware of? Pipeline Script snippet post { always { sh """ echo 'Link to

jenkins pipeline stage view does not show sub project stage build progress

笑着哭i 提交于 2019-12-11 03:06:19
问题 i am trying to run a jenkins job which calls other jobs, which i do by doing the following: node { stage ('Building Sub Project1') { res = build job: 'Sub Project1' stage ('Building Sub Project2') { build job: 'Sub Project2', parameters: [[$class: 'StringParameterValue', name: 'hash', value: res.buildVariables.hash]] } } } But unfortunately i see only the 2 stages that i've defined in this project. Is there a way to visualise the "sub" project stages that are being build in the background? 来源

jenkinsfile doesn't recognize @Grab [closed]

不问归期 提交于 2019-12-11 02:42:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I want to use @Grab to include a yaml parsing library inside my Jenkinsfile. I add this line in my Jenkinsfile: @Grab('org.yaml:snakeyaml:1.17') https://bitbucket.org/asomov/snakeyaml However, the Jenkins run can't recognize this and return an error. 回答1: You cannot use @Grab in pipelines at the moment. I doubt it

Export command in Jenkins pipeline

纵饮孤独 提交于 2019-12-11 01:48:25
问题 How to add an 'export' unix command in a Jenkins pipeline? I have a Jenkins 'stage' and 'steps' within it. What is the syntax for an export command. I need to set the environment variable 'PATH' using the export command. 回答1: You can update the $PATH like this: pipeline { agent { label 'docker' } stages { stage ('build') { steps { // JENKINSHOME is just a name to help readability withEnv(['PATH+JENKINSHOME=/home/jenkins/bin']) { echo "PATH is: $PATH" } } } } } When I run this the result is:

Can't find pipeline editor anymore

て烟熏妆下的殇ゞ 提交于 2019-12-11 01:39:45
问题 I have the Blue ocean beta plugin installed and cannot find the pipeline editor. Where should it be? I have the latest version of the plugin installed, I'm sure it used to be an obvious button you could click on when going to the blue ocean view, but it's not there for me anymore. 回答1: I encountered the same problem and posted a question in the Cloudbees Community. One of the Cloudbees engineers responded with this: "At the moment you can only edit Pipelines that have been created through the

How to fix unstable builds when thresholds are met?

余生长醉 提交于 2019-12-11 01:32:50
问题 My overall coverage is meeting the threshold, but still build is marked as Unstable. Does anyone know the reason for this? 16:53:04 [JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=75, maxClass=99, minMethod=75, maxMethod=99, minLine=75, maxLine=99, minBranch=40, maxBranch=99, minInstruction=65, maxInstruction=99, minComplexity=0, maxComplexity=99] 16:53:04 [JaCoCo plugin] Publishing the results.. 16:53:04 [JaCoCo plugin] Loading packages.. 16:53:04 [JaCoCo plugin] Done. 16

git clone without history using SCM

时光毁灭记忆、已成空白 提交于 2019-12-11 01:07:55
问题 Our project is huge and we would like to avoid cloning all git history. Is it possible to git clone passing depth=1 using checkout scm in Jenkins? I cannot find any documentation about how to configure SCM or how to pass arguments, if possible. Added: Found the documentation https://jenkins.io/doc/pipeline/steps/workflow-scm-step/#code-checkout-code-general-scm Type: int depth (optional) Set shallow clone depth, so that git will only download recent history of the project, saving time and

Jenkins pipeline script created dynamically

谁都会走 提交于 2019-12-10 23:08:52
问题 I am using a jenkins pipeline project. In the script I would like to write the parallel block in a dynamic way, since the number of nodes can change. For instance, from this: parallel( node1: { node(){ stage1() stage2() ... } }, node2: { node(){ stage1() stage2() ... } }, ... ) to something like this for (int i = 0; i < $NODE_NUMBER; i++) { "node${i}": { node (’namenode-' + ${i}) { something() } } but this way doesn’t work, Groovy/Jenkins is not happy about this syntax. Can someone suggest a

Grouping post conditions in a Jenkins declarative pipeline

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 21:48:28
问题 Is there a way to group post conditions in a Jenkins declarative pipeline ? For instance, I want to do the same thing for statuses aborted failure and success . Is there a shorter way to do it than the following ? post { aborted { sendNotification(currentBuild.result, "$LIST_NOTIFICATION_JENKINS") failure { sendNotification(currentBuild.result, "$LIST_NOTIFICATION_JENKINS") success { sendNotification(currentBuild.result, "$LIST_NOTIFICATION_JENKINS") } 回答1: There is the 'always' condition:

How do I fail a Jenkins build if a Docker Pipeline Plugin withRun command returns a non-zero exit code?

佐手、 提交于 2019-12-10 21:28:43
问题 I'm using the Docker Pipeline Plugin to execute my build scripts via Docker containers. I noticed that if I had a script return a non-zero exit code when executing within an inside() command, Jenkins would mark the pipeline execution as a failure. This example Jenkinsfile illustrates that scenario: docker.image('alpine').inside() { sh 'exit 1' } However, if I use the withRun() command, a similar Jenkinsfile will not cause the build to fail, even though the docker ps -l command shows that the