Bitbucket pipeline deployment issue
Asked by manish_taazaa:

There is some problem in bitbucket pipeline deployment. In case of multiple service deployment in single pipeline, If any specific service build process failed, then it marked the entire pipeline failed and skip the remaining services deployment which was in queue. it becomes very hard to re-initiate deployment for skipped services.


Answers:
author: Patrik S
body: Hello [@manish_taazaa](/t5/user/viewprofilepage/user-id/5168033) ,

Welcome to the community!

The way that pipelines identify if a command was successful or failed is by analyzing the exit code of the command. If a zero exit code is returned by the command you are executing, the command is considered successful, while when a non-zero exit code is returned, the command is considered a failure, the entire pipeline execution is stopped and the step is marked as failed.

If you would like the pipeline step to not stop when a command fails (return a non-zero exit code), you can use the following shell flag :

    - step: 
        script: 
           - set +e # Do not stop builds at first command failure
           - <rest of your commands>

This will change the default shell behavior, making the build not exit when a non-zero exit code is returned by a command, effectively making the Pipeline step not exit when a non-zero exit code is returned. The caveat of this workaround is that every step where you use this flag will always be considered successful, as the exit code will be ignored (see [Pipeline builds succeeds even on command failure](https://confluence.atlassian.com/bbkb/pipelines-builds-succeeds-even-on-command-failure-1142437808.html))

If you would like to still keep track of the failed steps, meaning that you would like to see the step failing in the UI, but the pipelines to proceed to the next steps, we have an open feature request for it, which you can find in the following link :

* <https://jira.atlassian.com/browse/BCLOUD-21670>

I would encourage you to Vote and add yourself as a watcher on that feature request, in case it matches the functionality you are looking for. Feel free to leave any comments on your use case on that feature as well, as this helps to give it traction.

Hope that helps! Let me know in case you have any questions.

Thank you, [@manish_taazaa](/t5/user/viewprofilepage/user-id/5168033) !

Patrik S

comments: author: manish_taazaa
body: How to use "allow_failure" in multi-step deployment and how to build all the steps even any one step gives error.


author: Patrik S
body: Hello [@manish_taazaa](/t5/user/viewprofilepage/user-id/5168033) ,

The "allow_failure" flag is currently not available as this is still a feature request. You can follow the feature request ticket [BCLOUD-21670](https://jira.atlassian.com/browse/BCLOUD-21670) for any updates in regard to the implementation of that feature.

The workaround would be to make the step always successful, regardless of whether a command fails, by adding the following instruction at all the steps you want to ignore errors in your yml file :

    - step: 
        script: 
           - set +e # Do not stop build at first command failure

Thank you, [@manish_taazaa](/t5/user/viewprofilepage/user-id/5168033) !

Patrik S


author: manish_taazaa
body: [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) The given solution will always show the step as "Success" even if you have failing tests.

I need to report failing tests and should show failed tests on the pipeline.

the step that failed should still show as "Failed" then continue to the next step. please help me.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/246951i4E91AF7A3F732A16/image-size/large?v=v2&px=999 "image.png")


author: Patrik S
body: Hey [@manish_taazaa](/t5/user/viewprofilepage/user-id/5168033) ,

Unfortunately, it's currently not possible for the step to fail and continue to the next steps. This is a feature request that is being tracked on [BCLOUD-21670](https://jira.atlassian.com/browse/BCLOUD-21670).

The only current workaround is to use the **set +e**flag in your script, but as you mentioned, the downside is that all the steps will show as "Success".

In this case, I would suggest voting and adding yourself as a watcher on [BCLOUD-21670](https://jira.atlassian.com/browse/BCLOUD-21670) to be informed about any progress on its implementation.

Thank you, [@manish_taazaa](/t5/user/viewprofilepage/user-id/5168033) !

Patrik S


Tags: bitbucket-cloud

cloud