jenkins-workflow

How to make SCM polling work with the Jenkins Workflow plugin

删除回忆录丶 提交于 2019-12-03 01:44:06
In a normal freestyle project, I configure the SCM plugin to point to the Git repo that I want to release, and I enable the "Poll SCM" option, which allows me to configure a Stash webhook to tell Jenkins whenever there has been a change to that repo. In this way, the job can be triggered whenever a change is pushed to the repo. But when I use a workflow instead of a freestyle project, the SCM of the code that I need to build is specified programmatically in the groovy workflow script, which means that it is not listening for the Stash webhook. Instead, the SCM that is configured directly in

Cannot use readMavenPom in Jenkinsfile

末鹿安然 提交于 2019-12-03 01:21:51
I am working on a Jenkinsfile for use with Jenkins 2.0. The readMavenPom method is not recognized. Is there some configuration I am missing to make this available? My Jenkinsfile: node { stage 'Checkout' checkout scm env.PATH = "${tool 'maven-3'}/bin:${env.PATH}" stage 'Build' def pom = readMavenPom file: 'pom.xml' echo "${pom}" sh "mvn -DskipTests=true verify" } When run, I get the following error: java.lang.NoSuchMethodError: No such DSL method 'readMavenPom' found among [AWSEBDeployment, archive, bat, build, catchError, checkout, deleteDir, dir, echo, emailext, error, fileExists, git, input

How do I implement a retry option for failed stages in Jenkins pipelines?

风格不统一 提交于 2019-12-03 01:04:35
问题 I have a Jenkinsfile with multiple stages and one of them is in fact another job (the deploy one) which can fail in some cases. I know that I can made prompts using Jenkinsfile but I don't really know how to implement a retry mechanism for this job. I want to be able to click on the failed stage and choose to retry it. 回答1: You should be able to combine retry + input to do that Something like that stage('deploy-test') { try { build 'yourJob' } catch(error) { echo "First build failed, let's

How can I reference the Jenkinsfile directory, with Pipeline?

荒凉一梦 提交于 2019-12-02 21:56:35
I have a groovy file, I want to run from the Jenkinsfile. ie. load script.groovy However, I am not sure how I can reference this file if it is stored in the same directory as the Jenkinsfile. I am loading the Jenkinsfile from git. I noticed it creates a folder called workspace@script . It does not place this in the workspace directory. I could hardcode the folder but I am not sure the rules on this and it seems a little redundant to check-out the code again. java.io.FileNotFoundException: /opt/jenkins_home/jobs/my_job/workspace/script.groovy (No such file or directory) By default it loads from

Create resusable jenkins pipeline script

我是研究僧i 提交于 2019-12-02 17:08:04
I am considering to use Jenkins pipeline script recently, one question is that I don't figure out a smart to way to create internal reusable utils code, imagine, I have a common function helloworld which will be used by lots of pipeline jobs, so I hope to create a utils.jar can injected it into the job classpath. I notice Jenkins have a similar concept with the global library , but my concern regarding this plugin: Since it is a plugin, so we need to install/upgrade it through jenkins plugin manager, then it may require reboot to apply the change, this is not what I want to see since utils may

How do I implement a retry option for failed stages in Jenkins pipelines?

别说谁变了你拦得住时间么 提交于 2019-12-02 16:35:17
I have a Jenkinsfile with multiple stages and one of them is in fact another job (the deploy one) which can fail in some cases. I know that I can made prompts using Jenkinsfile but I don't really know how to implement a retry mechanism for this job. I want to be able to click on the failed stage and choose to retry it. fchaillou You should be able to combine retry + input to do that Something like that stage('deploy-test') { try { build 'yourJob' } catch(error) { echo "First build failed, let's retry if accepted" retry(2) { input "Retry the job ?" build 'yourJob' } } } you could also use

Why won't groovy run in Jenkins pipeline?

和自甴很熟 提交于 2019-12-02 08:08:56
问题 I am currently trying to run a groovy script from my pipeline as one of my nodes, but I ran into this error: [CompanyName] Running shell script + ./ideainspect.groovy env: groovy: No such file or directory Also, I tried installing the plugin for groovy, but for some reason, it won't install. Whenever I refresh the page for tools, the installer goes away. Am I installing groovy wrong? Please help! Edit: Relevant Data stage 'Static Analysis' node { dir("Android/btMobileApp") { sh "./ideainspect

Jenkins Workflow: How to get or set step id

末鹿安然 提交于 2019-12-02 06:40:41
问题 We would like to reference a step inside a parallel task of a Jenkins workflow. But it seems that step IDs are created non deterministic for steps in multiple parallel tasks. For a input step it is possible to manually specify the step id. Is it either possible to specify a step id for a shell step or query the step id? The purpose is that we would like to create a link to a shell script inside a parallel task. 回答1: Indeed step IDs are not in general predictable in advance. Do you want to

Why won't groovy run in Jenkins pipeline?

大憨熊 提交于 2019-12-02 03:37:35
I am currently trying to run a groovy script from my pipeline as one of my nodes, but I ran into this error: [CompanyName] Running shell script + ./ideainspect.groovy env: groovy: No such file or directory Also, I tried installing the plugin for groovy, but for some reason, it won't install. Whenever I refresh the page for tools, the installer goes away. Am I installing groovy wrong? Please help! Edit: Relevant Data stage 'Static Analysis' node { dir("Android/btMobileApp") { sh "./ideainspect.groovy" sh "./gradlew checkstyle lintDebug" } } And the ideainspect.groovy file is an executable with

How to get SVN revision number in Jenkins Workflow Plugin?

前提是你 提交于 2019-12-01 13:11:12
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 "$svnHome/bin/svn info" def mvnHome = tool 'Maven' sh "export JAVA_HOME=/var/jenkins_home/java; $mvnHome/bin