换成pip3试一下
这个slave01连的是那个机器呀,是服务器中的还是那个镜像呀
(1)python3 -m pip3 install 也试过了,pipline script为:
`
pipeline {
//指定要在哪个节点上运行,通过节点标签指定
agent {
label ‘slave01’
}
stages {
stage("拉取自动化测试代码"){
steps{
git credentialsId: 'dc4c515b-8b8a-4023-bd4a-ea9286f7aa55', url: 'https://gitee.com/superlff888/autoTest.git'
}
}
stage("执行自动化测试"){
steps{
// 服务器搭建在了linux环境下了,所以用python3
sh 'python3 -m pip3 install -r requirements.txt -i https://pypi.douban.com/simple/'
sh 'python3 run.py ${env_name}'
}
}
stage("生成测试报告"){
steps{
allure includeProperties: false, jdk: '', results: [[path: 'reports/shop']]
}
}
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: '1310157572@qq.com'
}
}
}
}
`
(2) 执行结果:
这个autotset1的镜像起容器了吗,可以发下dokcer ps 或者 docker ps -a的截图吗
找不到pip的原因是master节点连不上子节点,所以使用默认的节点(master节点)进行执行,而Jenkins使用的是docker启动的方式,就会使用docker中的python
找不到子节点的原因是子节点容器的启动方式不太正确,master与slave节点不能互相通信,导致jenkins不能把请求发送到子节点上
可以参考官方镜像的描述来启动节点
https://hub.docker.com/r/jenkins/inbound-agent
注意要使用容器内网络ip,不要使用公网ip,使用公网ip的话,只能单向通信不能双向通信