我正在尝试使用包装阶段
wrap([$class: 'Xvfb', additionalOptions: '', assignedLabels: '', autoDisplayName: true, debug: true, displayNameOffset: 100, installationName: 'XVFB', parallelBuild: true]) {
如果我有下面几行的Jenkins文件,我如何首先启动Xvfb,然后开始运行测试套件?换句话说,如何包装舞台?
pipeline {
agent any
parameters{
choice(choices: 'chromenfirefoxnie' , description: 'choose browser name' , name: 'browser')
choice(choices: 'falsentrue' , 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'
}
}
}
谢谢。
以下是如何添加带超时的包装块:
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='''
}
}
}
}
您可以将第一阶段放入包装中
stages {
wrap([$class: 'Xvfb', ....) {
stage('Install Parent Project') {
steps {
sh 'mvn -f /var/lib/jenkins/workspace/ clean install -DskipTests=true'
}
}
}
}