2

I want to execute a powershell script (PS) upon successful build in Jenkins. This PS script basically deploys the application to web server. I see there are two plugins available Hudson Post Build Task and PostBuildScript Plugin to run post deployment scripts.

Can I use any one of these two? Any recommendation of one over other?

Also both plugins has a shell script option. Is that powershell script?

B--rian
  • 5,578
  • 10
  • 38
  • 89
LP13
  • 30,567
  • 53
  • 217
  • 400

2 Answers2

2

Actually, there's also a third... the one I've used and the best suited for your situation is probably the PowerShell Plugin

Dave
  • 161
  • 1
  • 7
  • 2
    ye i finally ended up using PowerShell Plugin. With "Hudson Post Build Task" & "PostbuildScript Plugin" i could not execute powershell scripts. The only issue with Powershell plugin is that, it doesnt appear under "post build " section. Instead it appears under "Builds" section – LP13 Feb 10 '16 at 17:52
  • But not having it be a 'post build' option might be a minor matter, depending on how your build is structured. I get that you want to deploy the ear/war on successful builds, but if your post build steps are only let's say, compiling artifacts, etc. It might be OK to deploy the ear/war if the artifact gathering fails. However if you are doing more intensive things in post build, yeah... I can see where this is an issue. – Dave Feb 10 '16 at 17:56
  • i use MSbuild to build the .net application. The build scripts ie. .proj file builds the application and drops the packaged output in some directory. AFTER THE BUILD is done i am running powershell script to extract & deploy package to web servers. and this step i wanted to do it in postbuild.. – LP13 Feb 10 '16 at 18:23
  • 1
    Another option (and I know this is not ideal), is to have an entirely separate job fired off by say, the 'Parameterized Trigger Plugin' (https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin) at the conclusion of your existing job, which only step is to deploy the ear/war via PS – Dave Feb 10 '16 at 18:30
2

To my knowledge, there is no way of executing a Powershell script in the post-build section of a Jenkins job (yet).

The search for the "Recommended way to deploy a war-file to a Tomcat using Jenkins?" is based on that observation, that Powershell scripts need to be included in the build section for Jenkins Version 2.32.3.

B--rian
  • 5,578
  • 10
  • 38
  • 89