Created
March 21, 2020 08:53
-
-
Save workze/a7e20f8c69691367a7fb6ba3eab39fe6 to your computer and use it in GitHub Desktop.
jenkins pipeline ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent { label 'xxx' } | |
options { timestamps() } | |
environment { | |
KW_PROJECT_NAME = 'xxx' | |
} | |
stages { | |
stage('Checkout') { | |
steps { | |
script { | |
iui_changed = iuiChanged() | |
handler_changed = handlerChanged() | |
} | |
} | |
} | |
stage('Build & KW') { | |
steps { | |
parallel Build: { | |
dir('integration') { | |
stash includes: 'xxx.tar.gz', | |
name: 'xxx' | |
} | |
}, KW: { | |
node('KW') { | |
dir('xxx') { | |
script { | |
if (handler_changed) { | |
try { | |
sh ''' | |
''' | |
} catch (Throwable e) { | |
sh 'echo kw-exception' | |
} | |
} | |
} | |
} | |
} | |
}, | |
failFast: true | |
} | |
} | |
stage('Deploy') { | |
agent { label "xxx" } | |
steps { | |
deleteDir() | |
unstash 'xxxx' | |
lock('xxx') { | |
sh ''' | |
''' | |
} | |
echo "After Deploy Serices" | |
} | |
} | |
stage('FT') { | |
when { | |
expression { | |
return handler_changed | |
} | |
} | |
agent { label 'xxx' } | |
steps { | |
deleteDir() | |
retry(240) { | |
sh "sleep 30s" | |
} | |
lock('xxx') { | |
} | |
} | |
post { | |
always { | |
step([ | |
$class : 'RobotPublisher', | |
disableArchiveOutput: true, | |
logFileName : 'log.html', | |
onlyCritical : false, | |
otherFiles : '', | |
outputFileName : 'output.xml', | |
outputPath : '.', | |
passThreshold : 10, | |
reportFileName : 'reprt.html', | |
unstableThreshold : 10 | |
]); | |
} | |
failure { | |
sh 'exit 1' | |
} | |
} | |
} | |
} | |
post { | |
failure { | |
mailOnFailure() | |
} | |
} | |
} | |
def mailOnFailure() { | |
if (env.EMAILABLE == 'false') { | |
return | |
} | |
def recipientProviders = ([ | |
[$class: 'CulpritsRecipientProvider'], | |
[$class: 'FirstFailingBuildSuspectsRecipientProvider'] | |
]) | |
def subject = 'xxx' | |
def to = '' | |
emailext body: "构建日志: <a href='${BUILD_URL}console'>${BUILD_URL}console</a>", recipientProviders: recipientProviders, subject: subject, to: to | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment