Mention some post conditions pipeline options that are used in a jenkinsfile

0 votes
Aug 28, 2019 in Jenkins by anonymous
2,056 views

1 answer to this question.

0 votes

We can mention some test conditions to run post the completion of stages in a pipeline.

Here's the code snippet:

post {
always {
echo “This block runs always !!!”
}
success {
echo “This block runs when the stages has a success status”
}
unstable {
echo “This block is run when the stages abort with an unstable status”
}
}

Here are the post conditions reserved for jenkinsfile:

always: Run the steps in the post section regardless of the completion status of the Pipeline’s or stage’s run.

unstable: Only run the steps in post if the current Pipeline’s or stage’s run has an "unstable" status, usually caused by test failures, code violations, etc.

aborted: Only run the steps in post if the current Pipeline’s or stage’s run has an “aborted” status.

success: Only run the steps in post if the current Pipeline’s or stage’s run has a "success" status.

failure: Only run the steps in post if the current Pipeline’s or stage’s run has a "failed" status.

changed: Only run the steps in post if the current Pipeline’s or stage’s run has a different completion status from its previous run.

cleanup: Run the steps in this post condition after every other post condition has been evaluated, regardless of the Pipeline or stage’s status.

answered Aug 28, 2019 by Sirajul
• 58,990 points

Related Questions In Jenkins

+4 votes
7 answers

How to set the pipeline name and description for a Jenkinsfile?

You can rename pipeline jobs in jenkins ...READ MORE

answered Oct 11, 2018 in Jenkins by Hannah
• 18,550 points
22,297 views
+1 vote
1 answer
0 votes
2 answers

how to execute a shell script post build step in Jenkins?

You could use the Post Build Task Plugin ...READ MORE

answered Jul 31, 2019 in Jenkins by Sirajul
• 58,990 points
18,156 views
+1 vote
1 answer

How to extract a substring of a string in a declarative pipeline code?

This would have been more easier using ...READ MORE

answered Aug 16, 2019 in Jenkins by Sirajul
• 58,990 points
16,580 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
953 views
+2 votes
1 answer
0 votes
1 answer
+5 votes
3 answers

How to trigger a Jenkins pipeline A in another Jenkins pipeline B?

You can run the following code, its ...READ MORE

answered Jul 5, 2018 in Jenkins by Sophie may
• 10,530 points
40,857 views