Pipeline流水线脚本
pipeline{
agent {
label 'slave1-apitest'
}
stages{
stage("拉取自动化测试代码"){
steps{
git credentialsId: '65623c68-96bc-4037-ab73-db5c091f358f', url: 'https://gitee.com/huangshao1989/api-framework.git'
}
}
stage("执行自动化测试代码"){
steps{
sh 'python -m pip install -r requirements.txt -i https://pypi.douban.com/simple/'
sh 'python run.py ${env_name}'
}
}
stage("生成测试报告"){
steps{
allure includeProperties: false, jdk: '', results: [[path: 'report/data']]
}
}
stage("发送邮件报告"){
steps{
emailext body: '''<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>$PROJECT_NAME-第$BUILD_NUMBER次构建日志</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"
offset="0">
<div>
<table width="95%" cellpadding="0" cellspacing="0"
style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<th align="center" colspan="2"><br />
<h2>构建信息</h2>
</th>
</tr>
<tr>
<td>
<ul>
<li>项目名称 : $PROJECT_NAME</li><br />
<li>详细测试日志 : <a href=${BUILD_URL}console target=\'_blank\'>${BUILD_URL}console</a></li><br />
<li>详细测试报告 : <a href=${JOB_URL}allure target=\'_blank\'>${JOB_URL}allure</a></li><br />
<li>触发原因: ${CAUSE}</li><br />
<li>项目 Url : <a href=‘$BUILD_URL’ target=\'_blank\'>$BUILD_URL</a></li><br />
</ul>
</td>
<td height="350px" style="overflow:hidden;display:block">${JELLY_SCRIPT,template="html"}<br/>
</tr>
</table>
</div>
</body>
</html>''', subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!', to: '[email protected],[email protected]'
}
}
stage("发送企业微信通知"){
steps{
sh 'python wx_notice.py ${BUILD_URL} ${username} ${password} ${wx_url} ${JOB_NAME} ${BUILD_NUMBER}'
}
}
stage("发送飞书通知"){
steps{
sh 'python feishu_notice.py ${BUILD_URL} ${username} ${password} ${feishu_url} ${JOB_NAME} ${BUILD_NUMBER}'
}
}
stage("发送钉钉通知"){
steps{
sh 'python dingding_notice.py ${BUILD_URL} ${username} ${password} ${dingding_url} ${JOB_NAME} ${BUILD_NUMBER}'
}
}
}
}
标签:脚本,pipeline,NAME,URL,NUMBER,steps,BUILD,流水线,stage From: https://www.cnblogs.com/shaohuang/p/17505987.html