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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Running a script on cancelation

I have two scripts 

1. /root/exec.sh

2. /root/clean.sh

 

When the pipeline is canceled or exited with error code ($? != 0) I want to executed /root/clean.sh

1 answer

1 vote

Hi @tbhaxor  and welcome to the community.

This is possible by adding an after-script section in your Pipelines script.

You can check the example in the following documentation, if you search for the after-script keyword:

If you want to run this only when the script fails or gets cancelled, you can make use of the default variable BITBUCKET_EXIT_CODE:

Is this something that works for you?

Kind regards,
Theodora

@Theodora Boudale  What would the value of BITBUCKET_EXIT_CODE when I manually cancel the pipeline?

Hi @tbhaxor ,

The after-script will not get executed if you manually stop the build. It will get executed only when the step it belongs to succeeds or fails.

That was my mistake, I apologize, I misunderstood your question.

We have a feature request for running the after-script even when the build is manually stopped:

I would suggest to add your vote (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features. You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

Implementation of new features is done as per our policy here https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html and any updates will be posted in the feature request.

Please feel free to let me know if you have any other questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

898 views 14 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you