You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Is there a way to report code analysis on sonarcube dashbaord even if the build fails? Is there a way to write a script in yml file to do the above? Please let me know.
Hey @Sandeep.Dash ,
My suggestion would for you to make use of the after-script functionality of Bitbucket Pipelines. With after-script you can define one or commands to be executed as soon as your step is completed, regardless if the step failed or succeed.
Please find below an example of using after-script keyword :
pipelines: default: - step: name: Build and test script: - npm install - npm test after-script: - echo "This is my first after script command"
- echo "This is my first after script command"
- ./my_script.sh #invoking a script
In the example above, the 3 commands of after-script section will be executed both if the prior npm commands fail or succeed. For more details about the after-script syntax you can refer to this documentation.
If you want the after-script to only be executed in one of these scenarios (only when step succeed or only when the step failed) you can make use of the environment variable BITBUCKET_EXIT_CODE - values can be 0 (success) or 1 (failed) - and create an if statement in your YML, like below :
- if [ "$BITBUCKET_EXIT_CODE" != 1 ]; then exit 0 ; fi - echo "This command will only be executed if the step failed"
You can also make use of pipes in the after-script section. Sonar has developed some pipes that can be used in Bitbucket pipelines which might be useful for your use-case :
Hope that helps to address your questions. Do let us know in case you have any doubt.
Thank you, @Sandeep.Dash .