Skip to content

Running BDDStack in the pipeline requires a Jenkinsfile update

Angelika Ehlers edited this page Feb 19, 2018 · 17 revisions

Replace:

node('master') {
	stage('Functional Test') {
	//the checkout is mandatory, otherwise functional test would fail
        echo "checking out source"
        echo "Build: ${BUILD_ID}"
        checkout scm
        dir('navunit') {
			try {
				sh './gradlew --debug --stacktrace phantomJsTest'
			} finally { 
				archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'
			}
        }
    }
}

with

//See https://github.com/jenkinsci/kubernetes-plugin
podTemplate(label: 'bddstack', name: 'bddstack', serviceAccount: 'jenkins', cloud: 'openshift', containers: [
  containerTemplate(
    name: 'jnlp',
    image: '172.50.0.2:5000/openshift/jenkins-slave-bddstack',
    resourceRequestCpu: '500m',
    resourceLimitCpu: '1000m',
    resourceRequestMemory: '1Gi',
    resourceLimitMemory: '4Gi',
    workingDir: '/home/jenkins',
    command: '',
    args: '${computer.jnlpmac} ${computer.name}'
  )
]) {
     node('bddstack') {
	stage('Functional Test') {
	//the checkout is mandatory, otherwise functional test would fail
          echo "checking out source"
          checkout scm
          dir('functional-tests') {
			try {
				sh './gradlew --debug --stacktrace chromeHeadlessTest'
			} finally { 
				archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'
                                archiveArtifacts allowEmptyArchive: true, artifacts: 'build/test-results/**/*'
                                junit 'build/test-results/**/*.xml'
			}
          }
        }
     }
   }

We also enabled firefoxHeadlessTest:

//See https://github.com/jenkinsci/kubernetes-plugin
podTemplate(label: 'bddstack', name: 'bddstack', serviceAccount: 'jenkins', cloud: 'openshift', containers: [
  containerTemplate(
    name: 'jnlp',
    image: '172.50.0.2:5000/openshift/jenkins-slave-bddstack',
    resourceRequestCpu: '500m',
    resourceLimitCpu: '1000m',
    resourceRequestMemory: '1Gi',
    resourceLimitMemory: '4Gi',
    workingDir: '/home/jenkins',
    command: '',
    args: '${computer.jnlpmac} ${computer.name}'
  )
]) {
     node('bddstack') {
	stage('Functional Test') {
	//the checkout is mandatory, otherwise functional test would fail
          echo "checking out source"
          checkout scm
          dir('functional-tests') {
			try {
                              sh 'Xvfb :1 -screen 0 1024x768x24 &;export DISPLAY=:1;./gradlew --debug --stacktrace firefoxHeadlessTest'
			} finally { 
				archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'
                                archiveArtifacts allowEmptyArchive: true, artifacts: 'build/test-results/**/*'
                                junit 'build/test-results/**/*.xml'
			}
          }
        }
     }
   }

Firefox does need the added commands to operate. As a caveat: we have not yet fully tested this inside a pipeline.