Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Execute next step if step fails

Joris Van Acoleyen October 22, 2020

I was wondering if it's possible to execute a step even if previous step failed.

I know there is something called after-script this can't be used it it needs to execute a defined step.

The purpose is because i need to start an instance run some things on it then shut it down but when it fails on the run part it will not shutdown the instance.

The code:

definitions  steps:    - step&Start_ec2        nameStart ec2 build server        imageamazon/aws-cli        script:          - aws ec2 start-instances --instance-ids id          - aws ec2 wait instance-running --instance-ids id
    - step&Stop_ec2        nameStop ec2 build server        imageamazon/aws-cli        script:          - aws ec2 stop-instances --instance-ids id          - aws ec2 wait instance-stopped --instance-ids id
    - step&build       nameBuild       script:          - pipeatlassian/ssh-run:0.2.6            variables:              SSH_USER$SSH_USER              SERVER$SERVER              COMMAND'echo "hello"'
pipelines:  branches:    master:      - step*Start_ec2      - step*build      - step*Stop_ec2

1 answer

1 vote
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 13, 2020

@Joris Van Acoleyen you can put steps in parallel, if it suits your case. Look at the advanced configuration section here https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/

 

Cheers, Galyna

Evan Rosal February 8, 2021

I have a similar issue where I am unable to use the parallel steps in my case. In simple scenario, I have something like this:

e2e: &e2e

   name: Run tests

   ...
- parallel:

     - step:

            <<: *e2e

     - step:

            <<: *e2e

- step:

   name: Zip files and generate reports

   ...

 

From the above, parallel step #1 might pass (successful) while parallel step #2 might have failures (failed) and I still want to continue to the next step (Zip files and generate reports) and display the pipeline results as still "Failed".

I've used the following but it shows successful all the time:

|| true

- set +e
after-script (not possible as I want to generate a consolidated report instead of multiple ones if this is placed on the parallel tests)

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2021

@Evan Rosalso in your case you could put tests results to different files in after scripts and then in the separate step you consolidate those results

 

Evan Rosal February 9, 2021

That can be done but the problem still is that the separate step to consolidate wont be executed if either one of the parallel tests before that step fails.

What I need is for the whole build to continue until the last step even if one of the steps fail.

Using - set +e in my script will continue it up until the last step but it wont show failed on the previous step. 

Like enrique piera serra likes this
Evan Rosal February 9, 2021

Also, as a reference, Gitlab CI has a flag called allow_failure: true that is similar to what I wanted in bitbucket pipeline

Like enrique piera serra likes this
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 12, 2021

@Evan Rosalok, I got it.

The thing is that bitbucket pipelines execute bash script. So you can find a way to do this right now through bash ignoring way.

For example make test || true.  Like this you can ignore the failure in bash, but still you will have test reports file I think.

 

Also, you may consider test report Bitbucket pipelines feature (however , there is no parallel test reports gathering feature).

If it is not enough , you may create a separate question in community , asking for something like some module to consolidate reports.

 

You also can submit Suggestion request marking the Component starting with "Pipelines - xxx"

From Pipelines - *** components you can choose what you like Pipelines - Test reports or Pipelines - Run failures, Pipelines - Pipes etc. There you explain your case and may make some proposition (like allow_failure, consolidated report etc.)

 

After submitting the ticket will be in gathering interest status and depending on how many people vote for that, the team will consider this in the future.

 

Perhaps, then we can think about the pipe, that union reports in one, e.g..

 

Thanks for helping us to improve the pipelines.

Arunkumar Ravikumar December 7, 2021

it would be really a nice feature to have , i am facing a similar issue today and was looking for answers

Like # people like this
Marc Andreu January 18, 2022

Me too, I need to aggregate Cypress reports of all the parallel steps and if any test fails it won't generate the report.

Marc Andreu January 18, 2022

@Halyna Berezovska 

You said above. "You also can submit Suggestion request marking the Component starting with "Pipelines - xxx""

Where exactly can we send this suggestion?

 

@Evan Rosal Did you submit such a suggestion? I can add voting to support that need.

 

Many thanks

Like Sarath Nagarajan likes this
Sarath Nagarajan January 24, 2022

Any luck on this? please share the suggestion link so that i can also vote it. Hence this can be looked up at the earliest

Like Kajsa likes this
Bon Stewart Sison June 22, 2022

Here's the ticket for the above feature suggestion

https://jira.atlassian.com/browse/BCLOUD-21670

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events