创建多分支pipeline
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4a05298be5d4ccee718f02ec4de7d9cc.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3ee9eb2389469db33d93c21001d97fde.png)
根据分支部署到不同的环境
pipeline {
agent any
stages {
stage("deploy to test") {
when {
branch 'master'
}
steps {
echo "deploy to master"
}
}
stage("deploy to prod") {
when {
branch 'main'
}
steps {
echo "deploy to main"
}
}
}
}
when指令的用法
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4614f2786492b1cf350879755945ca0f.png)
GitLab trigge