jenkins - Jenkins Pipelines:如何并行运行一个阶段?
问题描述
我想将一个阶段与两个阶段并行运行,所有这一切都在其他三个阶段之后进行。
像这样的东西(不是有效的语法):
pipeline {
stages {
stage('Build A') {
}
stage('Build B') {
}
stage('Build C') {
}
parallel {
stages {
stage('Build D1') {
}
stage('Build D2') {
}
}
stage('Build D3') {
}
}
}
}
有可能安排这种结构吗?
解决方案
做到这一点的方法是并行的顺序阶段。
pipeline {
agent none
stages {
stage("build and deploy on Windows and Linux") {
parallel {
stage("windows") {
agent {
label "windows"
}
stages {
stage("build") {
steps {
bat "run-build.bat"
}
}
stage("deploy") {
when {
branch "master"
}
steps {
bat "run-deploy.bat"
}
}
}
}
stage("linux") {
agent {
label "linux"
}
stages {
stage("build") {
steps {
sh "./run-build.sh"
}
}
stage("deploy") {
when {
branch "master"
}
steps {
sh "./run-deploy.sh"
}
}
}
}
}
}
}
}
推荐阅读
- python - 在不使用虚拟环境的情况下使用 miniconda/anaconda?
- javascript - 我是否正确嵌套了函数?
- git - 如何告诉 Git Clone 不要运行我的 .bashrc?
- python - 如何从pyserialtransfer的数字列表中重建python中的结构
- css - 定义标题高度
- ios - 如何使用 Firebase 数据创建和填充 SwiftUI 列表?
- c# - 来自列表 C# 的对象自毁
- c - LCM,然后以矩阵形式表示
- regex - Angular 9 - Validators.pattern('^[0-9][0-9][0-9]$') 与 012 等前导 0 数字不匹配
- postgresql - SpringBoot+Kotlin+Postgres 和 JSONB:“org.hibernate.MappingException:没有 JDBC 类型的方言映射”