What to do since PostBuild Script is deprecated

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

What to do since PostBuild Script is deprecated

john.peterson
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f4864991-9772-4d33-a192-b625acdee1ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: What to do since PostBuild Script is deprecated

Andrew Grimberg
On 11/10/2017 08:13 AM, john.peterson wrote:

> 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
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-

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/72e65658-5d53-ffe3-051b-c5bf180217cf%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What to do since PostBuild Script is deprecated

john.peterson
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.

On Friday, November 10, 2017 at 11:28:02 AM UTC-5, Andrew Grimberg wrote:
On 11/10/2017 08:13 AM, john.peterson wrote:

> 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

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:

<a onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FSingle%2BUse%2BSlave%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBJufCIh0H4-Oa0AifpnT8Lx7WtQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FSingle%2BUse%2BSlave%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBJufCIh0H4-Oa0AifpnT8Lx7WtQ&#39;;return true;" href="https://wiki.jenkins.io/display/JENKINS/Single+Use+Slave+Plugin" target="_blank" rel="nofollow">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-

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9a1cf854-6a7e-4988-8118-b1ef9d4faaef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: What to do since PostBuild Script is deprecated

john.peterson
In reply to this post by john.peterson
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...


On Friday, November 10, 2017 at 11:13:45 AM UTC-5, john.peterson wrote:
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5cf38cab-3567-4c59-b085-72aa6dfcb4e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.