jenkins的“重新启动测试”功能以并行方式重新启动所有测试

时间:2019-05-14 11:38:15

标签: jenkins parallel-testing

我正在并行运行几个jenkins测试。但是,当测试失败时,我想单独触发失败的测试。

我了解到“重新启动测试”功能是重新启动失败阶段的测试,但就我而言,它正在重新启动所有测试。

下面是我的jenkinsfile:

#!/usr/bin/env groovy

def docker_image
def factory_key 
pipeline {

  agent any   

  stages {          

    // Checkout git repository
    stage('Build & Prepare environment') {

      // Execute this stage only on non-master branches
      when {
        not {
          branch 'master'
        }
      }

      steps {
         sh "docker pull $DOCKER_IMAGE"         
      }
    }        

    // Launch tests
    stage('Test') {

      when {
        not {
          branch 'master'
        }
      }      

      parallel {

        stage('Testing deploy_demo on sles-12-factory-base using --terraform-config parameter..') {
          when {
            expression { currentBuild.result != 'SUCCESS' }
          }
          steps {
            withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'artifactory-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
              script {
                docker.image("$DOCKER_IMAGE").inside("-u ansible") {                                                                  
                  sh '/docker/entrypoint-test.sh "deploy_role --deploy-config configs/deploy_demo.cfg --terraform-config sles-12-factory-base.cfg --ignore-common-roles"'
                }
              }              
            }                         
          } 
        }       

        stage('Testing deploy_demo on rhel-7-factory-base using --terraform-config parameter..') {
          when {
            expression { currentBuild.result != 'SUCCESS' }
          }
          steps {            
            script {
             docker.image("$DOCKER_IMAGE").inside("-u ansible"){              
                withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'artifactory-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {                  
                  sh '/docker/entrypoint-test.sh "deploy_role --deploy-config configs/deploy_demo.cfg --terraform-config rhel-7-factory-base.cfg --ignore-common-roles"'                  
                }                                             
              }
            }             
          }
        }           

      }                            
    }        

  }
}

我在每个测试阶段添加了一个when表达式,以在currentBuild.result成功但不考虑它时停止重新触发测试。

when {
            expression { currentBuild.result != 'SUCCESS' }
      }

我正在尝试使用jenkins BlueOcean UI的“重新启动测试”链接。

Restart Test

任何帮助将不胜感激。

0 个答案:

没有答案