pipline在执行的docker镜像中添加hosts
在docker属性的args参数加上--add-host tests。abtc.com:120.1.1.65 即可
pipeline { agent any stages { stage("执行用例") { agent { docker { // label "master" image 'python3_pytest:lastest' args '--add-host tests。abtc.com:120.1.1.65 --add-host test.onp.com:8.0.6.31' } } steps { echo "**********************************git拉取master************************************" git url: 'https://e8ae5e54eb5fb@github.com/vc/test.git', branch: 'master' echo "**********************************执行用例 ****************************************" sh 'pwd;ls' sh 'pytest -n auto ./testcase/onev --html ./report/onev.html --junit-xml ./report/onev.xml' echo "**********************************执行完成 ****************************************" } post { always { // txt测试报告 junit 'report/onev.xml' // html测试报告 publishHTML (target: [ allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: './report', reportFiles: 'onev.html', reportName: "OneEV Report" ]) } } } } post { always { echo currentBuild.result } success { echo "success" // emailext body: '$DEFAULT_CONTENT', subject: '$DEFAULT_SUBJECT', to: '$DEFAULT_RECIPIENTS' } failure { echo "failure" emailext body: '$DEFAULT_CONTENT', subject: '$DEFAULT_SUBJECT', to: 'ci@v.com' } } }
鸡肉是我的最爱!