Re: pipeline post-action in Jenkinsfile ?

2016-05-07 Thread Mike Caspar

Cool.

Created a PR for a Jenkinsfile example that has a few steps and a 
try/catch block.


https://github.com/jenkinsci/pipeline-examples/pull/30

It would be great if someone did a quick check before putting it into 
master.


I had to move the mail into the try and catch blocks as putting the 
results into finally caused script access problems.


Mike

On 16-05-07 09:31 AM, Baptiste Mathus wrote:



Le 5 mai 2016 9:47 PM, "Mike Caspar" > a écrit :

>
> Awesome.
>
> This worked great.
>
> I managed to simply wrap a try around my whole file and then a 
catch/finally for success and failure.

>
> Craig, I'll look at the example. Thanks
>
> I did figure out that I needed to use the error tag with some text 
during my catch block and that properly set it the status to failed.. 
Cool.

>
> Where would be a good place to put this as an example in the docs 
for others  ?


Please add your examples there:
https://github.com/jenkinsci/pipeline-examples

Thanks a lot!

--
You received this message because you are subscribed to a topic in the 
Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6hy6Ut8XnLUCT5Br2JyjwzKQ6Vi%2BNyXPChCiq-JOP1nQ%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/572E05D9.3090306%40caspar.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-07 Thread Baptiste Mathus
Le 5 mai 2016 9:47 PM, "Mike Caspar"  a écrit :
>
> Awesome.
>
> This worked great.
>
> I managed to simply wrap a try around my whole file and then a
catch/finally for success and failure.
>
> Craig, I'll look at the example. Thanks
>
> I did figure out that I needed to use the error tag with some text during
my catch block and that properly set it the status to failed.. Cool.
>
> Where would be a good place to put this as an example in the docs for
others  ?

Please add your examples there:
https://github.com/jenkinsci/pipeline-examples

Thanks a lot!

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6hy6Ut8XnLUCT5Br2JyjwzKQ6Vi%2BNyXPChCiq-JOP1nQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-06 Thread Mike Caspar

Thanks.

That explains some of the weirdness I am having. Much appreciated.

Mike


On 16-05-06 07:56 AM, Antonio Muñiz wrote:
Take special precautions about unexpected exceptions thrown inside the 
finally block.
In that case script-security-plugin is not going to interpret approval 
requests correctly.


On Thu, May 5, 2016 at 9:47 PM, Mike Caspar > wrote:


Awesome.

This worked great.

I managed to simply wrap a try around my whole file and then a
catch/finally for success and failure.

Craig, I'll look at the example. Thanks

I did figure out that I needed to use the error tag with some text
during my catch block and that properly set it the status to
failed.. Cool.

Where would be a good place to put this as an example in the docs
for others  ?

Craig, any suggestions where I might put a section for try/catch
and "simulating" what was there before for others who will no
doubt find themselves in similar transitions ? Any thoughts are a
good place to start.

Mike

Oh.. thanks again to Craig Rodrigues and Baptiste Mathus


On 2016-05-05 3:38 PM, Craig Rodrigues wrote:

Hi,

Yes, in your pipeline script, you need to catch exceptions for
what you
want to do.  Be careful, if the build fails, you will need to set
currentBuild.status and re-throw the exception in order for the
build to be marked as failed.

Look at this example which I wrote:

https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy

--
Craig

On Thu, May 5, 2016 at 12:24 PM, Mike Caspar mailto:m...@caspar.com>> wrote:


try {
step 1
step 2
step 3
step 4
step 4
}
catch
{
task {send email of build status}
}
finally
{
task {send email of build status}
}

-- 
You received this message because you are subscribed to a topic

in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to jenkinsci-users+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVfqa72x317P1OO9zZnyvmP73vPcQyoH7PsH7OVfaRTRmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


-- 
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 jenkinsci-users+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/jenkinsci-users/a2bd3ac9-2a99-af64-bbee-3c403f0dfa13%40caspar.com

.


For more options, visit https://groups.google.com/d/optout.




--
Antonio Muñiz
Software Engineer
CloudBees, Inc.
--
You received this message because you are subscribed to a topic in the 
Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAJc7kzRsWdJoUqKwJA7SR2VbwSPj%3DJ-ii9GwWucBqV2LdjuytA%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/572CFB7C.8080900%40caspar.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-06 Thread Antonio Muñiz
Take special precautions about unexpected exceptions thrown inside the
finally block.
In that case script-security-plugin is not going to interpret approval
requests correctly.

On Thu, May 5, 2016 at 9:47 PM, Mike Caspar  wrote:

> Awesome.
>
> This worked great.
>
> I managed to simply wrap a try around my whole file and then a
> catch/finally for success and failure.
>
> Craig, I'll look at the example. Thanks
>
> I did figure out that I needed to use the error tag with some text during
> my catch block and that properly set it the status to failed.. Cool.
>
> Where would be a good place to put this as an example in the docs for
> others  ?
>
> Craig, any suggestions where I might put a section for try/catch and
> "simulating" what was there before for others who will no doubt find
> themselves in similar transitions ? Any thoughts are a good place to start.
>
> Mike
>
> Oh.. thanks again to Craig Rodrigues and Baptiste Mathus
>
>
> On 2016-05-05 3:38 PM, Craig Rodrigues wrote:
>
> Hi,
>
> Yes, in your pipeline script, you need to catch exceptions for what you
> want to do.  Be careful, if the build fails, you will need to set
> currentBuild.status and re-throw the exception in order for the build to be
> marked as failed.
>
> Look at this example which I wrote:
>
> https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy
>
> --
> Craig
>
> On Thu, May 5, 2016 at 12:24 PM, Mike Caspar < 
> m...@caspar.com> wrote:
>
>
>> try {
>> step 1
>> step 2
>> step 3
>> step 4
>> step 4
>> }
>> catch
>> {
>> task {send email of build status}
>> }
>> finally
>> {
>> task {send email of build status}
>> }
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVfqa72x317P1OO9zZnyvmP73vPcQyoH7PsH7OVfaRTRmQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/a2bd3ac9-2a99-af64-bbee-3c403f0dfa13%40caspar.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Antonio Muñiz
Software Engineer
CloudBees, Inc.

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAJc7kzRsWdJoUqKwJA7SR2VbwSPj%3DJ-ii9GwWucBqV2LdjuytA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-05 Thread Mike Caspar

Awesome.

This worked great.

I managed to simply wrap a try around my whole file and then a 
catch/finally for success and failure.


Craig, I'll look at the example. Thanks

I did figure out that I needed to use the error tag with some text 
during my catch block and that properly set it the status to failed.. Cool.


Where would be a good place to put this as an example in the docs for 
others  ?


Craig, any suggestions where I might put a section for try/catch and 
"simulating" what was there before for others who will no doubt find 
themselves in similar transitions ? Any thoughts are a good place to start.


Mike

Oh.. thanks again to Craig Rodrigues and Baptiste Mathus


On 2016-05-05 3:38 PM, Craig Rodrigues wrote:

Hi,

Yes, in your pipeline script, you need to catch exceptions for what you
want to do.  Be careful, if the build fails, you will need to set 
currentBuild.status and re-throw the exception in order for the build 
to be marked as failed.


Look at this example which I wrote:
https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy

--
Craig

On Thu, May 5, 2016 at 12:24 PM, Mike Caspar > wrote:



try {
step 1
step 2
step 3
step 4
step 4
}
catch
{
task {send email of build status}
}
finally
{
task {send email of build status}
}

--
You received this message because you are subscribed to a topic in the 
Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVfqa72x317P1OO9zZnyvmP73vPcQyoH7PsH7OVfaRTRmQ%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a2bd3ac9-2a99-af64-bbee-3c403f0dfa13%40caspar.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-05 Thread Craig Rodrigues
Hi,

Yes, in your pipeline script, you need to catch exceptions for what you
want to do.  Be careful, if the build fails, you will need to set
currentBuild.status and re-throw the exception in order for the build to be
marked as failed.

Look at this example which I wrote:
https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy

--
Craig

On Thu, May 5, 2016 at 12:24 PM, Mike Caspar  wrote:


> try {
> step 1
> step 2
> step 3
> step 4
> step 4
> }
> catch
> {
> task {send email of build status}
> }
> finally
> {
> task {send email of build status}
> }
>
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVfqa72x317P1OO9zZnyvmP73vPcQyoH7PsH7OVfaRTRmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-05 Thread Mike Caspar

Hi,

Things I am trying to define as post-action items (pass or fail).

slack update
email
html publish of test results
ssh of build results to a remote ssh
ironmq-notifier of results.
http post of JSON data to remote testing services (ie: ghostscript and 
runscope)

(stuff like that).


On 2016-05-05 3:24 PM, Mike Caspar wrote:

Thanks.

I like the try/catch/finally option if that would work.

I have setup a Pipeline Organization to auto-import my Scripts.

it sets up all the necessary repos  to build each one.

The problem occurs that I have no way to set the typical "email on 
success/email on failure" (I am also a contributor to a plugin that 
does Notification).


I could hardcode all my jobs or even use the Jenkins config DSL, but 
that would defeat the purpose of having the auto-import of a 
Multi-Branch Company setup.


I like the idea of helpers for other DSL items..  Maybe one to 
simulate the Config DSL from to set properties, endpoints, 
notifications somehow ?


What I really would like to do is use the DSL Script to reproduce the 
Notifications, emails, etc. within my script. (identified as post-action).


For now, I'll try to do it all in each script based on your exception.

Here's what I would like to do (from auto-import of Jenkinsfile to 
create new builds)


- If an error occurs, continue anyways

So, I guess what I'm looking for is.

try {
step 1
step 2
step 3
step 4
step 4
}
catch
{
task {send email of build status}
}
finally
{
task {send email of build status}
}


Thanks !! for your help.. If anything, an example of try/catch finally 
would be helpful. I would see what I could do to share back.


Much appreciated.

Mike Caspar




On 2016-05-05 3:12 PM, Baptiste Mathus wrote:


Hi,

There's no such concept in pipeline.

As Jesse explained: "the idea is that a Pipeline script is just a 
script: it runs the stuff you specified if and when you want it to. 
Whereas plugins contributing options to freestyle projects hardcode a 
lot of logic about when and whether something will happen, or make it 
a GUI configuration option, a Pipeline script is expected to define 
its own logic. We can always add convenience methods and DSLs on top 
of that for common usage patterns."


In your case, to do something on failure, you would typically use a 
try/catch/finally block.


If you are more specific on what you're trying to achieve, we might 
be able to help you more.


Cheers

Le 5 mai 2016 5:56 PM, "Mike Caspar"  a écrit :

Hi there,

I am converting a series of jobs to pipeline jobs.

I am not having any luck in finding the post-action stage  or
finding a way to do this.

a 'step' isn't appropriate to the situation (as it won't trigger
on failed).

If someone knows the answer to this, I would be happy to go over
to the docs and update once I get this working.

Ideas?





-- 
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 jenkinsci-users+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/jenkinsci-users/8b403f7e-a245-4e47-bd8f-185b5094d71a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in 
the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6Y%2BdXKsAU2_0tTommH-DLjqDa1h8NGx%2B_1wRycW3odVQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the 
Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/86731502-3669-3f2a-6a72-e392699deba4%40caspar.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 jenkinsci-users+unsubscr...@googlegroup

Re: pipeline post-action in Jenkinsfile ?

2016-05-05 Thread Mike Caspar

Thanks.

I like the try/catch/finally option if that would work.

I have setup a Pipeline Organization to auto-import my Scripts.

it sets up all the necessary repos  to build each one.

The problem occurs that I have no way to set the typical "email on 
success/email on failure" (I am also a contributor to a plugin that does 
Notification).


I could hardcode all my jobs or even use the Jenkins config DSL, but 
that would defeat the purpose of having the auto-import of a 
Multi-Branch Company setup.


I like the idea of helpers for other DSL items..  Maybe one to simulate 
the Config DSL from to set properties, endpoints, notifications somehow ?


What I really would like to do is use the DSL Script to reproduce the 
Notifications, emails, etc. within my script. (identified as post-action).


For now, I'll try to do it all in each script based on your exception.

Here's what I would like to do (from auto-import of Jenkinsfile to 
create new builds)


- If an error occurs, continue anyways

So, I guess what I'm looking for is.

try {
step 1
step 2
step 3
step 4
step 4
}
catch
{
task {send email of build status}
}
finally
{
task {send email of build status}
}


Thanks !! for your help.. If anything, an example of try/catch finally 
would be helpful. I would see what I could do to share back.


Much appreciated.

Mike Caspar




On 2016-05-05 3:12 PM, Baptiste Mathus wrote:


Hi,

There's no such concept in pipeline.

As Jesse explained: "the idea is that a Pipeline script is just a 
script: it runs the stuff you specified if and when you want it to. 
Whereas plugins contributing options to freestyle projects hardcode a 
lot of logic about when and whether something will happen, or make it 
a GUI configuration option, a Pipeline script is expected to define 
its own logic. We can always add convenience methods and DSLs on top 
of that for common usage patterns."


In your case, to do something on failure, you would typically use a 
try/catch/finally block.


If you are more specific on what you're trying to achieve, we might be 
able to help you more.


Cheers

Le 5 mai 2016 5:56 PM, "Mike Caspar" > a écrit :


Hi there,

I am converting a series of jobs to pipeline jobs.

I am not having any luck in finding the post-action stage  or
finding a way to do this.

a 'step' isn't appropriate to the situation (as it won't trigger
on failed).

If someone knows the answer to this, I would be happy to go over
to the docs and update once I get this working.

Ideas?





-- 
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 jenkinsci-users+unsubscr...@googlegroups.com
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/jenkinsci-users/8b403f7e-a245-4e47-bd8f-185b5094d71a%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the 
Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jenkinsci-users/5sN7BR7daOs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
jenkinsci-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6Y%2BdXKsAU2_0tTommH-DLjqDa1h8NGx%2B_1wRycW3odVQ%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/86731502-3669-3f2a-6a72-e392699deba4%40caspar.com.
For more options, visit https://groups.google.com/d/optout.


Re: pipeline post-action in Jenkinsfile ?

2016-05-05 Thread Baptiste Mathus
Hi,

There's no such concept in pipeline.

As Jesse explained: "the idea is that a Pipeline script is just a script:
it runs the stuff you specified if and when you want it to. Whereas plugins
contributing options to freestyle projects hardcode a lot of logic about
when and whether something will happen, or make it a GUI configuration
option, a Pipeline script is expected to define its own logic. We can
always add convenience methods and DSLs on top of that for common usage
patterns."

In your case, to do something on failure, you would typically use a
try/catch/finally block.

If you are more specific on what you're trying to achieve, we might be able
to help you more.

Cheers
Le 5 mai 2016 5:56 PM, "Mike Caspar"  a écrit :

> Hi there,
>
> I am converting a series of jobs to pipeline jobs.
>
> I am not having any luck in finding the post-action stage  or finding a
> way to do this.
>
> a 'step' isn't appropriate to the situation (as it won't trigger on
> failed).
>
> If someone knows the answer to this, I would be happy to go over to the
> docs and update once I get this working.
>
> Ideas?
>
>
>
>
>
> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/8b403f7e-a245-4e47-bd8f-185b5094d71a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6Y%2BdXKsAU2_0tTommH-DLjqDa1h8NGx%2B_1wRycW3odVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.