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

0 votes
Aug 28 in Jenkins by anonymous
29 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 by Sirajul
• 36,620 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
• 16,220 points
8,174 views
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 in Jenkins by Sirajul
• 36,620 points
484 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 in Jenkins by Sirajul
• 36,620 points
490 views
+5 votes
4 answers

How can I run a Jenkinsfile from a particular folder?

Consider the below points: The Freestyle project ...READ MORE

answered Mar 26, 2018 in Jenkins by anonymous
4,258 views
+13 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,380 points
209 views
0 votes
1 answer
0 votes
2 answers

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

If you are talking about executing another ...READ MORE

answered Jul 31 in Jenkins by Sirajul
• 36,620 points
6,302 views
+1 vote
1 answer