利用jekines进行批量部署(pipeline流水线模式)
1.新建节点
(1)【Manage Jenkins】–> 【Manage Nodes and Clouds】
(2)填写节点名称及远程工作目录(/mnt)
2.启动节点服务器
(1)安装java环境
(2)下载agent.jar包
(3)在节点服务器将节点明细页面里的命令用nohup方式启动,例如
nohup java -jar agent.jar -jnlpUrl https://jenkins-dev.huafaih.com/computer/节点名/slave-agent.jnlp -workDir “/mnt” &
3.新建item
(1)【jenkins】 -->【新建item】–>【流水线】
(2)填写流水线,保存
pipeline {
agent none
environment {
M2_HOME = '/usr/local/apache-maven-3.5.4'
}
stages {
stage('前端打包开始') {
agent {
node{
label 'xxzh-slave'
customWorkspace '/mnt/workspace/manager/web'
}
}
steps {
// Get some code from a GitHub repository
git branch: 'master',
credentialsId: 'git',
url: 'https://gitlab.test.com/xxzh/test-web.git'
sh 'npm install --unsafe-