Pipeline script - continue even if a script fails

Christophe Gouez November 24, 2016

I have serveral lines in my pipeline but I want all lines be executed even if a line fails.

For example, line2 return code 10 but I want line3 to be executed even if line2 is ko

pipelines:
  default:
    - step:
        script:
			- line1
			- line2
			- line3

How can I do that?

1 answer

1 accepted

13 votes
Answer accepted
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 24, 2016

Pipelines achieves the default behaviour of exiting on first error by prepending your script with the "set -e" bash command. You can "undo" this at any point in your script using the command "set +e". If you want all the commands in your script to execute regardless of errors then put "set +e" at the top of your script. If you just want to ignore the error for one particular command then put "set +e" before that command and "set -e" after it.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events