我有类似的设置
pipeline {
agent {
docker {
image 'openjdk:8-jdk'
}
}
stages {
stage("check out") {
steps {
sh 'touch fake_checkout'
sh 'ls'
stash 'src'
}
}
stage("Parallel Stages") {
parallel {
stage("P1") {
steps {
//deleteDir()
// above does not work, neither does cleanWs.
// Leads to sh: 0: getcwd() failed: No such file or directory when performing the touch
// Also using a specific agent here does not work.
unstash 'src'
sh 'ls' // shows p1.txt/p2.txt after some runs. The workspace is shared which is undesired.
sh 'touch p1.txt'
sh 'ls'
}
}
stage("P2") {
steps {
//deleteDir()
// above does not work, neither does cleanWs.
// Leads to sh: 0: getcwd() failed: No such file or directory when performing the touch
// Also using a specific agent here does not work.
unstash 'src'
sh 'ls' // shows p1.txt/p2.txt after some runs. The workspace is shared which is undesired.
sh 'touch p2.txt'
sh 'ls'
}
}
}
}
}
}
我想要的是每个阶段都并行拥有自己的干净工作区。 因此,并行级之间没有干扰,构建之间也没有干扰。
我还尝试了在全局范围内不使用代理,然后在每个阶段都使用特定代理。 但这不仅麻烦,而且仍然保留旧文件。