代码拉取完成,页面将自动刷新
// Node label that specifies on which slave(s) the job should run
BUILD_SLAVES_LABEL = 'build-servers'
// 'sha1' envvar is injected by Jenkins GHPRB plugin in case if build is started by pull request
IS_TRIGGERED_BY_PR = env.sha1?.trim()
GIT_BRANCH = '<unknown>'
// Text colours definition
def GREEN( String msg ) { return "\u001B[32m${msg}\u001B[0m" }
def YELLOW( String msg ) { return "\u001B[33m${msg}\u001B[0m" }
def RED( String msg ) { return "\u001B[31m${msg}\u001B[0m" }
def getCause(def build) {
while(build.previousBuild) {
build = build.previousBuild
}
return build.rawBuild.getCause(hudson.model.Cause$UserIdCause)
}
def getCauseDescription(def build) {
return getCause(build).shortDescription
}
pipeline {
agent {
label "${BUILD_SLAVES_LABEL}"
}
options {
ansiColor('xterm')
}
stages {
stage ("Initial") {
steps {
echo GREEN("${getCauseDescription(currentBuild)}")
script {
// If build is triggered by PR, use PR branch, otherwise use master
if (IS_TRIGGERED_BY_PR) {
GIT_BRANCH = env.sha1
} else {
GIT_BRANCH = 'master'
}
}
echo GREEN("Branch: $GIT_BRANCH")
// Debug: print all the build envvars
// echo sh(returnStdout: true, script: 'env')
sh "mvn --version"
}
}
stage ("Prepare (triggered by PR)") {
when { expression { IS_TRIGGERED_BY_PR } }
steps {
echo "${GREEN('PR:')} ${ghprbPullAuthorLoginMention} ${ghprbPullLink} $ghprbPullTitle"
}
}
stage ("Prepare (triggered by hand)") {
when { not { expression { IS_TRIGGERED_BY_PR } } }
steps {
echo GREEN("Triggered by hand, so building for master branch")
deleteDir() /* clean up workspace */
git 'git@github.com:checkstyle/checkstyle.git' /* clone the master branch */
}
}
stage('Build') {
parallel {
stage('Package') {
steps {
sh "mvn -e -B package"
}
}
}
}
}
post {
always {
// Clean up workspace
deleteDir()
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。