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 error
Asked
Active
Viewed 518 times
0

human
- 637
- 4
- 15
- 41
2 Answers
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.

Naveen Thiyagarajan
- 568
- 6
- 13
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