What to do since PostBuild Script is deprecated

23 views
Skip to first unread message

john.peterson

unread,
Nov 10, 2017, 11:13:45 AM11/10/17
to Jenkins Users
We have been using PostBuild Script to execute the following command on the remote machine (as Build Steps > Execute Windows Batch Command):

Shutdown  -s  -t:0     (I think I have that correct)

We have to do this to make sure that NO MATTER WHAT our remote PC (VM) is shutdown, otherwise, occasionally, a queued script will begin execution on the already open VM.

How can we do this and NOT use the PostBuild Script plugin?

We were running 1.58 in the past and are just now updating to 2.87

Andrew Grimberg

unread,
Nov 10, 2017, 11:28:02 AM11/10/17
to jenkins...@googlegroups.com, john.peterson
Greetings John,

For us, we keep a copy of the plugin around and upload it to new Jenkins
instances that we stand up as we have some very specific uses of it that
none of the other plugins handle and our jobs are all under code review
via Jenkins Job Builder so we know that no malicious extras are showing
up in the post script.

For your use case though, I might suggest the following additional plugin:

https://wiki.jenkins.io/display/JENKINS/Single+Use+Slave+Plugin

That will allow you to make your instances single use, but you do still
need to have a way of cleaning up any now offlined systems.

If you're doing dynamic build instances via JClouds (or the OpenStack
plugin), each job has the ability to define a build node be single-use.
The plugin will properly reap out instances that have been used once
when doing this.

From personal experience, if you're using the EC2 plugin, this doesn't
work, I've got a cron hack that I've got in place that makes use of the
Single Use Slave Plugin and some custom groovy and awscli to get similar
functionality as the the JClouds (which I would be using for EC2 but
it's failing to handle a configuration properly) and OpenStack plugins.

-Andy-

signature.asc

john.peterson

unread,
Nov 10, 2017, 11:55:55 AM11/10/17
to Jenkins Users
Excellent suggestion.  And the "race condition" the plugin mentions is exactly what was happening.

We are running VMware VM's via vSphere Cloud plugin.  And our jobs are set to shutdown and revert.  But, if a job HAPPENS to grab the VM before it shuts down, it keeps running and tries to run a job on a dirty VM!

Thanks.

john.peterson

unread,
Nov 10, 2017, 12:28:33 PM11/10/17
to Jenkins Users
I installed Single Use and removed Post Build.  But upon further evaluation, I wonder if my problems were partly my own fault anyway?  In the Node Configurations I had:

Availability: Take this agent online when in demand, and offline when idle
In Demand Delay: 0
Idle Delay: 10
Disconnect After Limited Builds: 0
What to do when slave is disconnected: Shutdown and Revert

I wonder if my "Disconnect After Limited Builds = 0" was my problem in the first place?

I still suspect that there is a race condition idle window during the 10 seconds though...
Reply all
Reply to author
Forward
0 new messages