Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Pipeline 'Wrap' Stages for Xvfb start

I'm trying to wrap stages by using:

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

If I have Jenkins file with below lines, how can I start the Xvfb first then start running the tests suite? In other words how to wrap the stages?

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'
        }
    }
}

Thanks.

like image 239
Nael Marwan Avatar asked Aug 01 '18 11:08

Nael Marwan


1 Answers

Here is how to add the wrap block with timeout:

    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='''
        }
        }
    }      
    }
like image 103
Nael Marwan Avatar answered Nov 19 '22 19:11

Nael Marwan