Xvfb 开始的 Jenkins 管道“包装”阶段

Nae*_*wad 6 selenium selenium-chromedriver jenkins-groovy jenkins-pipeline

我正在尝试使用以下方法包装阶段:

      wrap([$class: 'Xvfb', additionalOptions: '', assignedLabels: '', autoDisplayName: true, debug: true, displayNameOffset: 100, installationName: 'XVFB', parallelBuild: true]) {
Run Code Online (Sandbox Code Playgroud)

如果我有下面几行的 Jenkins 文件,我怎样才能先启动 Xvfb 然后开始运行测试套件?换句话说,如何包装阶段?

pipeline {

agent any 
             parameters{
             choice(choices: 'chrome\nfirefox\nie' , description: 'choose browser name' , name: 'browser')
             choice(choices: 'false\ntrue'  , description: 'Not running on Selenium Grid?' , name: 'localRun')
        }

stages {
      stage('Install Parent Project') {
        steps {
        sh 'mvn -f /var/lib/jenkins/workspace/ clean install -DskipTests=true'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢。

Nae*_*wad 5

以下是添加带超时的 wrap 块的方法:

    stage('Run Tests Suite') {
        steps {
         timeout(45) {
         wrap([$class: 'Xvfb', additionalOptions: '', assignedLabels: '', autoDisplayName: true, debug: true, displayNameOffset: 0, installationName: 'XVFB', parallelBuild: true, screen: '1024x758x24', timeout: 25]) {
        sh 'mvn  -f /var/lib/jenkins/workspace/... test -DlocalRun=${localRun} -Dbrowser=${browser} -DxmlPath='''
        }
        }
    }      
    }
Run Code Online (Sandbox Code Playgroud)


yon*_*ong 0

您可以将第一阶段放在包装内

stages {
    wrap([$class: 'Xvfb', ....) {
        stage('Install Parent Project') {
            steps {
            sh 'mvn -f /var/lib/jenkins/workspace/ clean install -DskipTests=true'
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)