Connect Jenkins to Test Companion
Analyze a failed Jenkins build in your IDE. Paste the build URL into Test Companion to get the root cause and a suggested fix.
When a Jenkins build fails, you read the console output in the browser, then switch to your IDE to find the cause. Test Companion removes that switch. Paste the failed build URL into the chat. Test Companion reads the console output and the test artifacts from the build. It compares them with the code in your workspace, then explains why the test failed.
Test Companion reaches Jenkins directly from your machine. Your Jenkins server never needs to be public.
Prerequisites
Ensure you have the following:
- Test Companion is installed in your IDE and you are signed in.
- Your Jenkins server is reachable from your machine. A server on a private network needs VPN or direct network access.
- You have a Jenkins API token. To create one, navigate to your Jenkins user page, open Configure, then add a token under API Token. The exact menu path depends on your Jenkins version.
- Your Jenkins account has read access to the job. Test Companion reads the console output and the archived test results.
- The repository that the failed build belongs to is open in your IDE.
Enter your Jenkins API token
The first time you analyze a Jenkins build, your IDE opens an input box for your Jenkins username, then a second one for your API token. Paste the token into that input box. The box masks the token as you type.
Do not paste the token into the Test Companion chat. The chat treats anything you type as a message for the AI, so a token pasted there becomes part of the conversation instead of a stored secret. The input box is the only place that stores it.
Your IDE holds the token in its own secret storage on your machine. The token never reaches a BrowserStack server. When the token stops working, for example after you revoke it in Jenkins, the input box appears again for a new one.
Check out the branch that CI ran
Test Companion compares the CI failure against the files in your workspace. Check out the branch that the failed build used before you paste the URL.
On a matching branch, Test Companion writes the fix to your files. On a different branch, it still explains the failure. The fix then arrives as code for you to copy, because the file is not in your workspace to edit.
Analyze a failed build
To get the root cause of a failed build, follow these steps:
- Navigate to the failed build in Jenkins.
-
Copy the complete URL from the browser address bar. A build URL looks like this:
https://<jenkins-host>/job/<job-name>/<build-number>/A multibranch or folder job repeats the
jobsegment for each level:https://<jenkins-host>/job/<folder>/job/<branch>/<build-number>/ - Open the Test Companion panel in your IDE.
- Paste the URL into the chat box. On a new line, type what you want Test Companion to do, for example,
analyze the failuresorfix the failures. - Press Enter, or click Send message (➤).
Paste the whole URL. When a segment is missing, Test Companion tells you in the chat that the URL is incomplete. Copy it again from the address bar.
You can ask Test Companion to analyze the failures or to fix them in your workspace. Test Companion works from the evidence it fetched, so it does not run or restart anything on your Jenkins server.
A build with more than one failing test is analyzed as one task. The CI Failure Analysis block lists each failing test with its own error output, and the summary at the end covers every failure.
What Test Companion reads from the build
Test Companion signs in to your Jenkins server, then fetches the failure evidence from the build. The chat first shows a summary line with the number of failed jobs and failed tests. A CI Failure Analysis block follows it.
The block reports the following details:
- The job name and the build number.
- The build title.
- The branch and the commit that CI used.
- The result of the build, such as
failure. - Each failing test, with the error output from the console log.
Review the fix
Test Companion ends the task with Task Completed and a short summary. The summary names the failing test and the line that failed. It quotes the evidence from the console log, then shows the change as a before and after code block.
What happens next depends on your branch:
- Your branch matches the CI branch: Test Companion saves a checkpoint of your workspace, then writes the change to your files. Click Changes to review the edits, or Restore to undo them. Run the test again to confirm it passes.
- Your branch does not match: Test Companion names the branch that holds the file. The fix appears as before and after code. Check out that branch, apply the change, then run the test.
Confirm the fix in CI
Test Companion fixes the failure in your local files. It does not start a build on your Jenkins server.
To confirm the fix in CI, follow these steps:
- Run the fixed test locally and confirm it passes.
- Commit the change and push it to your repository.
- Start the Jenkins build again, or wait for your trigger to run it, then check that the build passes.
When the cause is not in your code
Not every CI failure is a bug in your test. Test Companion grounds its explanation in the console log. When the evidence points to the environment or the infrastructure rather than your test code, Test Companion says so in the summary. It does not change your test.
A missing environment variable on the Jenkins agent is one example. Fix the cause in your pipeline, then run the build again.
Next steps
- Fix failed tests: Fix failures from the Failure Analysis panel, an imported Allure or JUnit report, the Automate dashboard, or the chat.
- Connect GitHub Actions to Test Companion: Analyze a failed GitHub Actions run the same way.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!