0

My automation project is setup in Jenkins pipeline. I am using custom webdriverio service in wdio config file. I tried const buildNum = process.env.BUILD_NUMBER; but it returns null. Also I get this errorenter image description here

human
  • 637
  • 4
  • 15
  • 41

2 Answers2

0

I do this in my project:

In the wdio-conf file i have this variable declared above the exports

const buildUrl = process.env.BUILD_URL || '';

In the jenkins, i have the below while triggering the test:

BUILD_URL=${BUILD_URL} npm test

This passes in the URL when triggered from jenkins or assign '' when not triggered from jenkins.

0

You need to add build step in shell file first as below..

export BUILD_NUMBER=${BUILD_NUMBER}

Then call process.env.BUILD_NUMBER

For Windows bat file add below..

SET BUILD_NUMBER=%BUILD_NUMBER%

Then call process.env.BUILD_NUMBER

Govind
  • 483
  • 5
  • 8