browserstack / automate-node-samples

Sample mocha, protractor, nightwatchjs, wd parallel testing code for running selenium with BrowserStack Automate
https://www.browserstack.com/automate/node
45 stars 26 forks source link

How to specify the environment variable BROWSERSTACK_BUILD_NAME to generate test report #25

Open phucgame opened 3 years ago

phucgame commented 3 years ago

Reference: --> https://www.browserstack.com/docs/automate/selenium/jenkins?ref=jenkins_plugin#JenkinsUI

wati123321 commented 3 years ago

The BrowserStack Jenkins plugin will directly set the build name for the test. It sets the Environment variable BROWSERSTACK_BUILD_NAME.

phucgame commented 3 years ago

@wati123321 Please help to review Here is full console log for specified build, then still failed with build not found ...

======================================== FSSCM.check completed in 12.686 seconds [BrowserStack] Local: Starting BrowserStack Local... [BrowserStack] Local: Started [BrowserStack] BROWSERSTACK_USERNAME=phuclegame1 [BrowserStack] BROWSERSTACK_ACCESS_KEY=**** [BrowserStack] BROWSERSTACK_BUILD=jenkins-project_aaa-7 [BrowserStack] BROWSERSTACK_BUILD_NAME=jenkins-project_aaa-7 [BrowserStack] BROWSERSTACK_LOCAL=true [BrowserStack] BROWSERSTACK_LOCAL_IDENTIFIER=53e3f298-5cd5-4b93-b3dd-4866acdddc46-project_aaa__7 [project_aaa] $ cmd /c call C:\Users\phuc\AppData\Local\Temp\jenkins8923147995851973098.bat

C:\Users\phuc.jenkins\workspace\project_aaa>browserstack-cypress run --build-name jenkins-project_aaa-7 [12/25/2020, 4:43:56 PM] - info: Reading config from C:\Users\phuc.jenkins\workspace\project_aaa\browserstack.json [12/25/2020, 4:43:57 PM] - info: Reading username from the environment variable BROWSERSTACK_USERNAME [12/25/2020, 4:43:57 PM] - info: Reading access key from the environment variable BROWSERSTACK_ACCESS_KEY [12/25/2020, 4:43:57 PM] - info: Reading local setting from the environment variable BROWSERSTACK_LOCAL [12/25/2020, 4:43:57 PM] - info: Reading local identifier from the environment variable BROWSERSTACK_LOCAL_IDENTIFIER [12/25/2020, 4:43:57 PM] - info: Validating the config [12/25/2020, 4:43:57 PM] - info: Creating tests.zip with files in . [12/25/2020, 4:43:57 PM] - info: Uploading the tests to BrowserStack [12/25/2020, 4:43:59 PM] - info: Uploaded tests successfully (bs://93c111964aa3170916bf3b787f4cdf85668d1e2a) [12/25/2020, 4:43:59 PM] - info: Deleted tests.zip successfully. [12/25/2020, 4:43:59 PM] - info: Browsers list: Windows 10 / Chrome (latest), Windows 10 / Firefox (latest), Windows 10 / Edge (latest) [12/25/2020, 4:43:59 PM] - info: Local is set to: true (you will now be able to test localhost / private URLs) [12/25/2020, 4:43:59 PM] - info: Parallels limit specified: 3 [12/25/2020, 4:44:01 PM] - warn: No npm dependencies specified - your specs might fail if they need any packages to be installed before running. [12/25/2020, 4:44:01 PM] - warn: Read more about npm dependencies here: https://www.browserstack.com/docs/automate/cypress/npm-packages. You can suppress this warning by using --disable-npm-warning flag. [12/25/2020, 4:44:01 PM] - info: Success! Build created with build id: 20950429036ef452f313f5d7677019cff55d69ed [12/25/2020, 4:44:01 PM] - info: Visit the Automate dashboard for real-time test reporting: https://automate.browserstack.com/dashboard/v2/builds/20950429036ef452f313f5d7677019cff55d69ed [12/25/2020, 4:44:01 PM] - info: Exiting the CLI, but your build is still running. You can use the --sync option to keep getting test updates. You can also use the build-info 20950429036ef452f313f5d7677019cff55d69ed command now. [BrowserStack] Local: Stopping BrowserStack Local... [BrowserStack] Local: Stopped [BrowserStack] Generating BrowserStack Test Report [BrowserStack] BrowserStack Project identified as : AUTOMATE [BrowserStack] [ERROR] BrowserStackException occurred while fetching build: com.browserstack.automate.exception.AutomateException: Build not found by name: jenkins-project_aaa-7 [BrowserStack] BrowserStack Report Status: Failed Finished: SUCCESS

Namrata-m13 commented 3 years ago

@phucgame You can generate the reports using the CLI functionality as mentioned in the following link, https://www.browserstack.com/docs/automate/cypress/generate-reports.

We will let you know once we have added support for Cypress reports in the Jenkins plugin. Meanwhile, you can use the above-mentioned method to generate reports using Cypress on BrowserStack.

msilesgap commented 3 years ago

I'm having the same issue trying to generate the report

[7/9/2021, 11:20:58 PM] - error: Generating report for the build 29 failed. with error: 
{
  "message": "Build not found"
}
[BrowserStack] Generating BrowserStack Cypress Test Report
[BrowserStack] BrowserStack Cypress Project identified as : AUTOMATE
[BrowserStack] [ERROR] BrowserStack Cypress Report not generated, build name mismatch.
[BrowserStack] BrowserStack Cypress Report Status: Failed
Finished: SUCCESS
Tae-juss commented 3 years ago

@msilesgap You can generate HTML reports with Cypress at BrowserStack. Embedded reports within Jenkins is not supported at the moment.

For reference: https://www.browserstack.com/docs/automate/cypress/generate-reports

Tasmi123 commented 3 years ago

I am also getting the same error. How to set this variable in the parallel config JSON file for testNG?

Swapnil-Titar commented 2 years ago

Anyone got the solution for this problem, with Ruby 3.x I am getting same error...

alwaysshiftingleft commented 2 years ago

if you are looking to generate Cypress Test Report with Browserstack using Cypress, I was able to generate it now with the below configuration in Jenkins image image

BROWSERSTACK_BUILD_NAME set by the BrowserStack plugin and i am still try to figure out if it can be send from the code or as variable (custom name)

ghost commented 2 years ago

BROWSERSTACK_BUILD_NAME (variable name) will need to be kept as is and cannot be modified to a custom name since the BrowserStack Plugin generates the Build Name (value) at runtime. This Build name is consumed by the BrowserStack Cypress Test Report Action to map the session on the BrowserStack Platform with the results to be published on Jenkins.

If you have any further queries with respect to the BrowserStack plugin, you may want to reach out to BrowserStack Support.

hayaalresheq94 commented 1 year ago

hey was this issue fixed? I am fixing the exact issue

bhumikababbar commented 1 year ago

@ hayaalresheq94

You can try and follow the steps mentioned by abhimanyu1589