Search code examples
jenkinsgroovyjenkins-pluginsxvfbjenkins-2

Set the screen resolution inside a xfvb wrap in a Jenkins pipeline


In a Jenkins 2.0 pipeline, I'm using code similar to

wrap([$class: 'Xvfb']) {
  // execute selenium tests
}

As expected, this xvfb session uses the default screen resolution (1024x768x8?). I would like to override it.

According to the documentation at https://github.com/jenkinsci/xvfb-plugin, the Xvfb plugin has a Screen member that controls the resolution. What is the syntax for doing so? I've tried

wrap([$class: 'Xvfb'](Screen:'1440x900x24')) {
  // execute selenium tests
}

wrap([$class: 'Xvfb'][Screen:'1440x900x24']) {
  // execute selenium tests
}

and

wrap([$class: 'Xvfb']) {
  Screen = '1440x900x24'
  // execute selenium tests
}

Solution

  • i believe config goes into the same map, so

    wrap([$class: 'Xvfb', screen: '1440x900x24']) {
      // execute selenium tests
    }
    

    Should work. And you shouldn't need the square brackets either