# Revert back to previous build image

**URL:** <https://community.jenkins.io/t/revert-back-to-previous-build-image/3752>\
**Category:** Ask a question\
**Created:** [September 12, 2022, 7:27pm UTC](https://community.jenkins.io/t/revert-back-to-previous-build-image/3752 "2022-09-12T19:27:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjaneyawnish](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@anjaneyawnish](https://community.jenkins.io/u/anjaneyawnish)\
**Post date:** [September 12, 2022, 7:27pm UTC](https://community.jenkins.io/t/revert-back-to-previous-build-image/3752/1 "2022-09-12T19:27:34Z")

</div>

How to revert back to previous build image if the current build fails. (Using pipeline code)

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [September 14, 2022, 2:39am UTC](https://community.jenkins.io/t/revert-back-to-previous-build-image/3752/2 "2022-09-14T02:39:16Z")

</div>

How would you do it from the command line without Jenkins? Do that same thing from an `sh` step, a `bat` step, or a `powershell` step.

Declarative Pipeline has the [`post` section](https://www.jenkins.io/doc/book/pipeline/syntax/#post) that can perform specific actions when its associated step fails. Scripted Pipeline can catch exceptions and perform actions after those exceptions.
