jenkins-workflow

Clean builds with Multibranch Workflow

吃可爱长大的小学妹 提交于 2020-01-23 04:33:38
问题 Using Multibranch Workflow, the command to check out looks like checkout scm I can't find a way to tell Jenkins to perform a clean checkout. By "clean," I mean it should remove all files from the workspace that aren't under version control. 回答1: I'm not sure if this answers the original question or not (I couldn't tell if the intention was to leave some files in the workspace) but why not just remove the workspace first, this would allow a clean checkout: stage ('Clean') { deleteDir() } stage

Jenkins Workflow Plugin Using a Groovy Library

╄→гoц情女王★ 提交于 2020-01-23 03:04:32
问题 As I'm writing more and more Groovy to use with the Jenkins Workflow plugin I've started getting to the point where I've got re-usable code that could be used in multiple scripts. What would be the best way of sharing this code? Is it possible to produce my own .jar with the shared code in and utilize this from within the Workflow script? Or is there a simpler way? 回答1: You can use Global Lib as pointed in other comments and/or use the load step to load you own scripts from somewhere (i.e.

Set build number for Jenkins workflow (pipeline) builds

寵の児 提交于 2020-01-22 08:52:10
问题 I am migrating jenkins-workflow job to new template based workflow job. Because the build number is used as part of the version of build artifacts the workflow produces I have to start build number of the new workflow with a number greater than the old workflow. Unfortunately 'Next Build Number' plugin does not work with workflow pipeline. Anybody knows a good way do this? 回答1: Try running below script in Jenkins Script Console.. Change "workFlow" to your Jobname def job = Jenkins.instance

Start a job multiple times concurrently with workflow plugin

六眼飞鱼酱① 提交于 2020-01-20 02:26:52
问题 I am trying to run one job 5 times concurrently using the workflow plugin. here is the snippet: def concurrent=[:] for (int i = 0; i < 5; i++) { concurrent["concurrent${i}"] = { build job: 'test_job', parameters: [[$class: 'StringParameterValue', name:'queue', value: 'automation_prod.q'],[$class: 'StringParameterValue', name:'dummy', value: "${i}"]] } } parallel concurrent this snippet causes the the test_job to run only once. I need it running 5 times concurrently. thanks! 回答1: There is no

Start a job multiple times concurrently with workflow plugin

不打扰是莪最后的温柔 提交于 2020-01-20 02:26:39
问题 I am trying to run one job 5 times concurrently using the workflow plugin. here is the snippet: def concurrent=[:] for (int i = 0; i < 5; i++) { concurrent["concurrent${i}"] = { build job: 'test_job', parameters: [[$class: 'StringParameterValue', name:'queue', value: 'automation_prod.q'],[$class: 'StringParameterValue', name:'dummy', value: "${i}"]] } } parallel concurrent this snippet causes the the test_job to run only once. I need it running 5 times concurrently. thanks! 回答1: There is no

Cannot start Jenkins server

≯℡__Kan透↙ 提交于 2020-01-17 03:10:11
问题 Cannot start jenkins. giving below logs when try to restart but doesnt work - -bash-3.2$ ./jenkins.sh start Jenkins is currently stopped... Starting Jenkins with command cd /eas/jenkins;/eas/jenkins/jenkins_jre/jre1.7.0_51/bin/java -Xms1024m -Xmx2048m - XX:MaxPermSize=512m -DJENKINS_HOME=/eas/jenkins/home -jar jenkins.war -bash-3.2$ standard in must be a tty Please help! 回答1: No, adding to sudoers file didnt solve it. there was issue with JVM where JDK was not able to initialize because of

Jenkins Workflow Multibranch allow for specifying Jenkinsfile path

≯℡__Kan透↙ 提交于 2020-01-13 08:21:09
问题 It seems like now you can only have a single Jenkinsfile in a single location in your project when using Multibranch type. Is there a way to configure so I can place the Jenkinsfile somewhere else than in the root of the project under the name Jenkinsfile. There's hope, as there's an option of Fixed Configuration, maybe this is a feature for the future, but I would much appreciate the option, as in the current situation I do not have the option to run everything as one nicely compiled

How can I disable security checks for Jenkins pipeline builds

送分小仙女□ 提交于 2020-01-10 03:51:12
问题 I'm running Jenkins in a local trusted environment where I'm trying to run this pipeline. This Jenkinsfile is checked into git. #!groovy node('master') { def ver = pomVersion() echo "Building version $ver" } def pomVersion(){ def pomtext = readFile('pom.xml') def pomx = new XmlParser().parseText(pomtext) pomx.version.text() } The first few times I ran the build, I needed to manually approve changes (Jenkins->Mange Jenkins-> In-process Script Approval). Now I get this Exception and there is

How to get e-mail address of current Jenkins user to use in groovy script

主宰稳场 提交于 2020-01-01 08:28:08
问题 I've created a groovy script for the new Jenkins Workflow Plugin, https://github.com/jenkinsci/workflow-plugin. I want it to send a mail to the user who started the job when it needs input for the next step. I've tried to search the API but I can't find anything about getting the users email address. I would think of something like this. import hudson.model.User def user = User.current() def mailAddress = user.getMailAddress() Is there a way to get the current Jenkins user' address in groovy?

Jenkins Groovy how to call methods from @NonCPS method without ending pipeline

馋奶兔 提交于 2019-12-31 22:43:20
问题 I need to parse some JSON in a Jenkins Pipeline and call some regular methods in a loop, however the script always exits after the first function call. How to do this? import groovy.json.JsonSlurper import com.cloudbees.groovy.cps.NonCPS @NonCPS def myMethod(String json) { def jsonSlurper = new JsonSlurper() def jsonObject = jsonSlurper(json) jsonObject.each { obj -> switch(obj.name) { case "foo": doAThing(obj) break case "bar": doAnotherThing(obj) break } } } In the above example, even with