所以我设法在运行两个作业的Jenkins管道中获得并行构建执行:“单元测试”和“E2E测试”,但我能使其工作的唯一方法是在单个“测试”阶段内,如下所示:
pipeline {
agent any
stages {
stage('Testing') {
steps {
parallel("Unit Tests": {
echo "Running Tests"
build 'Jenkins Job 1'
},
"E2E Tests": {
build 'Jenkins Job2'
}
)
}
}
stage('Deploy') {
steps {
parallel("first": {
echo "Open a ticket to deploy"
},
"second": {
echo "Confirm when ticket was approved"
}
)
}
}
}
}
那么,我们如何在单独的阶段视图中获取两个构建作业,同时保持它们并行运行?我无法做到这一点......
答案 0 :(得分:0)
尝试将其更改为:
pipeline {
agent any
stages {
stage('Tests') {
steps {
script {
def tests = [:]
stage("Unit Tests") {
tests["Unit Tests"] = {
build 'Jenkins Job 1'
}
}
stage("E2E Tests") {
tests["E2E Tests"] = {
build 'Jenkins Job 2'
}
}
parallel tests
}
}
}
}
}