1,由于默认插件源在国外服务器,大多数网络无法顺利下载,需修改国内插件源地址: cd jenkins_home/updates sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && \ sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json 然后重启Jenkins:http://192.168.0.14:30006/restart 2,先安装pipeline插件。 pipeline { agent any stages { stage('1,拉取代码') { steps { echo "1" } } stage('1,代码编译') { steps { echo "2" } } stage('1,单元测试') { steps { echo "3" } } } }
拉取代码:
pipeline { agent any parameters { choice choices: ['192.168.0.11:/root/a.git', '192.168.0.11:/root/b.git', '192.168.0.11:/root/c.git'], description: '请选择要发布项目的git地址', name: 'git' choice choices: ['192.168.0.10', '192.168.0.11', '192.168.0.12'], description: '请选择要发布项目的服务器', name: 'host' } stages { stage('1,拉取代码') { steps { echo "1" } } stage('1,代码编译') { steps { echo "2" } } stage('1,单元测试') { steps { echo "3" } } } }