webdriverio icon indicating copy to clipboard operation
webdriverio copied to clipboard

[🐛 Bug]: BrowserStack build identifier is not set when BROWSERSTACK_BUILD_NAME environment variable is set

Open kwiniarski opened this issue 10 months ago • 7 comments

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.35.1

Node.js Version

v20.9.0

Mode

Standalone Mode

Which capabilities are you using?

[
  {
    browserName: 'Chrome',
    'bstack:options': {
      projectName: 'Pinta',
      buildName: 'LOCAL',
      consoleLogs: 'verbose',
      networkLogs: true,
      local: true,
      debug: true,
      buildTag: 'desktop',
      browserVersion: '120.0',
      os: 'Windows',
      osVersion: '11',
      wdioService: '8.35.1',
      buildIdentifier: '${BUILD_NUMBER}'
    }
  },
  {
    browserName: 'Safari',
    'bstack:options': {
      projectName: 'Pinta',
      buildName: 'LOCAL',
      consoleLogs: 'verbose',
      networkLogs: true,
      local: true,
      debug: true,
      buildTag: 'desktop',
      browserVersion: '15.6',
      os: 'OS X',
      osVersion: 'Monterey',
      wdioService: '8.35.1',
      buildIdentifier: '${BUILD_NUMBER}'
    }
  }
]

What happened?

I'm using WebdriverIO with BrowserStack service and I have noticed that when I set build name through BROWSERSTACK_BUILD_NAME environment variable, then setting build identifier has no effect. Digging a little into the code I have found this condition in launcher.ts which effectively terminates processing of build identifier when BROWSERSTACK_BUILD_NAME is set.

https://github.com/webdriverio/webdriverio/blob/fa5f02f24b64372d2791814bde1306788319e30e/packages/wdio-browserstack-service/src/launcher.ts#L701-L705

What is your expected behavior?

No response

How to reproduce the bug.

Just set up BROWSERSTACK_BUILD_NAME variable and then run tests using browserstack-service. In BrowserStack dashboard you will see that following build are not numbered. All test sessions are appended to the one, already existing build.

Relevant log output

There is no relevant output for this bug in logs.

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • [X] I have searched the existing issues

kwiniarski avatar Apr 12 '24 09:04 kwiniarski

buildIdentifier: '${BUILD_NUMBER}'

It seems like you are also setting the buildIdentifier in your capabilities here. Can you remove this entry and try again? Also can you verify that your environment variables were set correctly by printing them out via e.g. console.log(process.env. BROWSERSTACK_BUILD_NAME).

christian-bromann avatar Apr 12 '24 12:04 christian-bromann

I think I have tried all combinations already. But checked them again. When environment variables are set then adding buildIdentifier to the service options or capabilities options or both at the same time has no effect. My build name in BrowserStack has no number.

But when I remove environment variables and hardcode build name in configuration, then setting buildIdentifier in service options works as expected. All my builds are numbered in BrowserStack.

kwiniarski avatar Apr 13 '24 06:04 kwiniarski

@kwiniarski can you provide a minimal reproducible example?

christian-bromann avatar Apr 15 '24 05:04 christian-bromann

I can't post the repo where I have this, but I will try to extract the minimal code. I think it will be helpful because I also have another potential bug with BrowserStack there.

kwiniarski avatar Apr 15 '24 18:04 kwiniarski

I have created repository with simple example that reproduces described issue: https://github.com/kwiniarski/wdio-browserstack-stencil. Steps to reproduce are in the README.md

kwiniarski avatar Apr 20 '24 18:04 kwiniarski

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

wdio-bot avatar May 28 '24 04:05 wdio-bot

@kwiniarski thanks for providing an example. We would appreciate any help identifying if this is a bug related to WebdriverIO and potential fixes for this. Cheers!

christian-bromann avatar May 28 '24 04:05 christian-bromann