jenkins-workflow

Email-ext and Workflow/Pipeline - some tokens not being expanded?

一个人想着一个人 提交于 2019-12-04 20:55:08
问题 I'm trying to use the email-ext plugin in a Jenkins pipeline job, but most of the tokens I take for granted when using email-ext in a freestyle job aren't being expanded? e.g. node { emailext body: '${DEFAULT_CONTENT}', mimeType: 'text/html', replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', to: '$DEFAULT_RECIPIENTS' } Generates the email: Subject: $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS! Body: $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output

Jenkins Workflow Plugin Using a Groovy Library

喜欢而已 提交于 2019-12-04 14:59:50
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? 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. your SCM just checked out previously). More info about load : https://github.com/jenkinsci/workflow-plugin

Kick off a job after manual approval in jenkins

北战南征 提交于 2019-12-04 10:49:37
问题 I have a requirement of trigerring a Job B after Job A executes successfully. After Job A executes successfully , an email notification will be sent to the approver . The approver will receive an email and click on the mail link . He will be routed to Jenkins page where he will approve the execution of Job B . I am not sure which plugin to use where I can mention the name of the approver , how the approver can click on the link and simple say "approve" after logging in to the Jenkins page.

Cannot use readMavenPom in Jenkinsfile

余生颓废 提交于 2019-12-04 08:56:01
问题 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,

How to get stdout and stderr from single Jenkins Pipeline parallel blocks?

◇◆丶佛笑我妖孽 提交于 2019-12-04 03:33:47
问题 I'm using a parallel block into my Jenkinsfile to execute concurrently some tests, but all the outputs are getting mixed up. This is an extract of my Jenkinsfile, as an example: // do some IT against different databases stage name: 'IT' parallel ( mysqlIT: { node { executeMysqlIT() } }, oracleIT: { node { executeOracleIT() } } ) Please note that, as suggested here I'm running a new node within each parallel , so they get properly parallelized and each of them gets its own workspace. What

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

╄→尐↘猪︶ㄣ 提交于 2019-12-04 01:19:41
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? I found a way: import hudson.model.AbstractProject import hudson.tasks.Mailer import hudson.model

Jenkinsfile build log

二次信任 提交于 2019-12-04 00:05:59
问题 Is there any builtin variable that gives access to the text of the currently executing build? I tried using something like currentBuild.log , currentBuild.buildLog but without any luck. 回答1: Actually it is possible using currentBuild.rawBuild.log or better (not deprecated) currentBuild.rawBuild.getLog(100) (for the last 100 lines), reference: http://javadoc.jenkins-ci.org/hudson/model/Run.html#getLog-int- 回答2: I searched a lot for a solution to analyze the log. use rawBuild was not OK,

Updating Jira tickets from Jenkins workflow (jenkinsfile)

前提是你 提交于 2019-12-03 16:50:47
How can I update a jira issue from within a Jenkinsfile (jenkins-worflow/pipeline) ? Is there a way I could use the Jira Issue Updater plugin as a step in the Jenkinsfile? I know I could use the Jira RestAPI, but I'm trying to figure out if I can re-use the functionality provided by the jira-updater-issue . What I'm looking for is a something similar to the example below calling Junit archiver, and atifact archiver, but calling jira updater. node { git url: 'https://github.com/jglick/simple-maven-project-with-tests.git' def mvnHome = tool 'M3' sh "${mvnHome}/bin/mvn -B -Dmaven.test.failure

Parsing an XML file within a Jenkins pipeline

折月煮酒 提交于 2019-12-03 15:11:10
I have an XML file which I'd like to use as input for a pipeline script. Problem is the XMLParser isn't serializable so I put it in a NonCPS function, but I lost the Node object because of that. This is the pipeline script: def buildPlanPath = 'C:\\buildPlan_test.xml' @NonCPS groovy.util.Node getBuildPlan(path) { new XmlParser().parseText(readFile(path)) } node { //def buildPlan = new XmlParser().parseText(readFile(buildPlanPath)) groovy.util.Node buildPlan = getBuildPlan(buildPlanPath) println buildPlan.getClass() println buildPlan println buildPlan.branch } This is an input sample: <branch

Email-ext and Workflow/Pipeline - some tokens not being expanded?

流过昼夜 提交于 2019-12-03 13:23:20
I'm trying to use the email-ext plugin in a Jenkins pipeline job, but most of the tokens I take for granted when using email-ext in a freestyle job aren't being expanded? e.g. node { emailext body: '${DEFAULT_CONTENT}', mimeType: 'text/html', replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', to: '$DEFAULT_RECIPIENTS' } Generates the email: Subject: $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS! Body: $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results. Which are, in fairness, what is set in the general configuration.