3

I'm using Jenkins CI and I would like to add some post-build actions.

I've tried to follow suggestions from Execute Shell Script after post build in Jenkins post, but I cannot find such option (Post build task) which should allow me to execute shell commands. I can select Execute shell, but only for Build.

Here are my all options:

Jenkins - Add post-build action

Transcript:

Add post-build action:

  • Aggregate downstream test results
  • Archive the artifacts
  • Build other projects
  • Console output (build log) parsing
  • GitHub PR: add labels
  • GitHub PR: close PR
  • GitHub PR: post comment
  • GitHub PR: remove labels
  • GitHub PR: set PR status
  • Publish HTML reports
  • Publish JUnit test result report
  • Publish Javadoc
  • Record fingerprints of files to track usage
  • Use publishers from another project
  • Git Publisher
  • Build other projects (manual step)
  • E-mail Notification
  • Editable Email Notification
  • Set build status on GitHub commit [deprecated]
  • Set status for GitHub commit [universal]
  • Trigger parameterized build on other projects
  • Delete workspace when build is done

What am I missing?


Basically I need this to destroy my VM instance in case of provisioning error (e.g. vagrant destroy -f).

I'm using Jenkins ver. 2.7.1.

Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743
  • 1
    Possible duplicate of [Execute Shell Script after post build in Jenkins](http://stackoverflow.com/questions/11160363/execute-shell-script-after-post-build-in-jenkins) – StephenKing Jul 30 '16 at 16:20
  • I see it's not listed in your list, but for me, _Post build task_ shows up in a fresh install. I've added it as an answer, as it's a bit hard to illustrate in comments. (Jenkins 2.7.1 with postbuild-task 1.8) – StephenKing Jul 30 '16 at 16:29
  • Did you restart Jenkins after plugin installation? After I remove the plugin (and restart Jenkins) this option is gone, so it really comes from that plugin. – StephenKing Jul 30 '16 at 16:34
  • Ok, my mistake, I think the plugin was called _Hudson Post build task_, so I was confused that I've it already, but I didn't. I thought by having _post-build action_ that means that I have this plugin. – kenorb Jul 30 '16 at 16:51
  • I think this question can be actually closed as duplicate. – kenorb Jul 30 '16 at 16:52

1 Answers1

10

Use the Add post-build action button and select Post build task, which is provided by the mentioned Post build task plugin:

enter image description here

Afterwards, you have Tasks, each with an input field Script, where you can execute your commands:

enter image description here

StephenKing
  • 36,187
  • 11
  • 83
  • 112