我有一个并行测试的常规脚本,但是无法从jenkins UI手动重新启动Installation1 / Installation2阶段。还有其他方法可以使我重新启动特定阶段吗?
pipeline {
agent {label ''}
stages {
stage('Check workspace') {
steps {
}
}
stage('Installation') {
parallel{
stage('Installation 1')
{
agent {label ''}
steps {
}
}
}
stage('Installation 2')
{
agent {label ''}
steps {
}
}
}
}
}
stage('Test') {
parallel{
stage(' Tests 1'){
agent {label ''}
steps {
}
}
stage(' Tests 2'){
agent {label ''}
steps {
}
}
}
}
stage('Report') {
steps {
}
}
}
}
答案 0 :(得分:0)
您可以在Jenkinsfile中将installation1和installation2阶段定义为函数,并在测试失败时调用它们。这些功能可以用于安装阶段,也可以在测试失败时重新安装。
def installation1() {
stage('Installation 1')
{
agent {label ''}
steps {
}
}
}
def installation2() {
stage('Installation 2')
{
agent {label ''}
steps {
}
}
}
在并行步骤中,可以调用以下功能。测试失败时,请使用try-catch调用安装函数。
stage('Test') {
try {
"TEST YOUR INSTALLATION"
} catch(error) {
echo "First test failed, let's retry installation if accepted"
retry(2) {
input "Retry the installation ?"
parallel{
installation1(),
installation2()
}
}
}
}
此代码未经测试。希望对您有所帮助:)