Re: Can I have a reusable “post” block for my jenkins pipelines?

2018-08-20 Thread Craig Rodrigues
red 888,

I want the exact same thing, i.e. a common post method which I can pass
arguments to, such as:

commonPost{email='ema...@somewhere.blah', notifySlack=true}

etc.

If you get something to work, please post a reference to an existing
pipeline with this.
Thanks!
--
Craig

On Mon, Aug 20, 2018 at 12:51 PM red 888  wrote:

> Hello yes thats what im after (although your second example doesn't have
> any steps). Sorry didn't check this thread in a while.
>
> It would also be great if I could actually pass in args so it could be
> like
> commonPost{arg1 = 'blah', arg2 = 'balh'}
>
>
>
>

-- 
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%3DrPVeNF8OhJvzBu-zTnpouUeQkQB_XdZRDmrVOSX1gnhepvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I have a reusable “post” block for my jenkins pipelines?

2018-08-20 Thread red 888
Hello yes thats what im after (although your second example doesn't have 
any steps). Sorry didn't check this thread in a while. 

It would also be great if I could actually pass in args so it could be like 
commonPost{arg1 = 'blah', arg2 = 'balh'}




On Tuesday, August 7, 2018 at 8:10:56 AM UTC-4, Jan Monterrubio wrote:
>
> So, I think what you want is:
>
> Project 1 Jenkins File:
>
> pipeline {
>
> stages {
> Stage(‘’npm i’){}
> } 
> commonPost()
> }
>
> Project 2 Jenkins file
> Pipeline{
> Script {
> Echo{
> }
> }
> commonPost()
> }
>
> Am I getting that correctly? 
>
>
> On Fri, Aug 3, 2018 at 08:20 red 888 > 
> wrote:
>
>> wait there seems to be confusion about what i am asking for look at my SO 
>> post: 
>> https://stackoverflow.com/questions/51508234/can-i-have-a-reusable-post-block-for-my-jenkins-pipelines
>>  
>>
>> I also ready use shared libs, all my pipelines are there. Between those 
>> several pipelines they all have a post block that is nearly identical. I 
>> want to reference a parameterized post block ONLY. My post block now is 
>> like 80 lines of code at the end of each pipeline thats nearly tthe same. 
>> even after moving most of the post block steps into separate groovy files 
>> (that are referenced in the post block) the whole post block is still large.
>>
>> On Thursday, August 2, 2018 at 3:13:56 PM UTC-4, Jan Monterrubio wrote:
>>>
>>> We do this in our CI. Basically the shared library has some variable 
>>> parameters you can override and it lets you control what happens based on 
>>> those. I’ll see if I can scrounge up a sample later today.
>>>
>>> On Thu, Aug 2, 2018 at 11:04 red 888  wrote:
>>>
>> how does that work though? My pipelines are already in shared libraries. 
>>>> I want a shared post block specifically.
>>>>
>>>>
>>>> On Monday, July 30, 2018 at 7:33:21 AM UTC-4, Johan Abildskov wrote:
>>>>>
>>>>> You should be able to do this with Shared Libraries: 
>>>>> https://jenkins.io/doc/book/pipeline/shared-libraries/
>>>>>
>>>>> On Thursday, July 26, 2018 at 9:22:53 PM UTC+2, red 888 wrote:
>>>>>>
>>>>>> I have many jenkins pipelines for several different platforms but my 
>>>>>> "post{}" block for all those pipelines is pretty samey. And its quite 
>>>>>> large 
>>>>>> at this point because I include success,unstable,failure and aborted in 
>>>>>> it.
>>>>>>
>>>>>>
>>>>>> Is there a way to parameterize a reusable post{} block I can import 
>>>>>> in all my pipelines? I'd like to be able to import it and pass it params 
>>>>>> as 
>>>>>> well (because while its *almost* the same it varies very slightly 
>>>>>> for different pipelines).
>>>>>>
>>>>>>
>>>>>> Here is an example post block that is currently copy and pasted 
>>>>>> inside all my pipeline{}s
>>>>>>
>>>>>>
>>>>>> post {
>>>>>> success{
>>>>>> script {
>>>>>> // I'd like to be able to pass in values for param1 and 
>>>>>> param2
>>>>>> someGroovyScript {
>>>>>> param1 = 'blah1'
>>>>>> param2 = 'blah2'
>>>>>> }
>>>>>> // maybe id want a conditional here that does something with 
>>>>>> a passed in param
>>>>>> if (param3 == 'blah3') {
>>>>>> echo 'doing something'
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>> unstable{
>>>>>> ... you get the idea
>>>>>> }
>>>>>> aborted{
>>>>>> ... you get the idea
>>>>>> }
>>>>>> failure{
>>>>>> ... you get the idea
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> -- 
>>>> 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 
>>>&

Re: Can I have a reusable “post” block for my jenkins pipelines?

2018-08-07 Thread Jan Monterrubio
So, I think what you want is:

Project 1 Jenkins File:

pipeline {

stages {
Stage(‘’npm i’){}
}
commonPost()
}

Project 2 Jenkins file
Pipeline{
Script {
Echo{
}
}
commonPost()
}

Am I getting that correctly?


On Fri, Aug 3, 2018 at 08:20 red 888  wrote:

> wait there seems to be confusion about what i am asking for look at my SO
> post:
> https://stackoverflow.com/questions/51508234/can-i-have-a-reusable-post-block-for-my-jenkins-pipelines
>
>
> I also ready use shared libs, all my pipelines are there. Between those
> several pipelines they all have a post block that is nearly identical. I
> want to reference a parameterized post block ONLY. My post block now is
> like 80 lines of code at the end of each pipeline thats nearly tthe same.
> even after moving most of the post block steps into separate groovy files
> (that are referenced in the post block) the whole post block is still large.
>
> On Thursday, August 2, 2018 at 3:13:56 PM UTC-4, Jan Monterrubio wrote:
>>
>> We do this in our CI. Basically the shared library has some variable
>> parameters you can override and it lets you control what happens based on
>> those. I’ll see if I can scrounge up a sample later today.
>>
>> On Thu, Aug 2, 2018 at 11:04 red 888  wrote:
>>
> how does that work though? My pipelines are already in shared libraries. I
>>> want a shared post block specifically.
>>>
>>>
>>> On Monday, July 30, 2018 at 7:33:21 AM UTC-4, Johan Abildskov wrote:
>>>>
>>>> You should be able to do this with Shared Libraries:
>>>> https://jenkins.io/doc/book/pipeline/shared-libraries/
>>>>
>>>> On Thursday, July 26, 2018 at 9:22:53 PM UTC+2, red 888 wrote:
>>>>>
>>>>> I have many jenkins pipelines for several different platforms but my
>>>>> "post{}" block for all those pipelines is pretty samey. And its quite 
>>>>> large
>>>>> at this point because I include success,unstable,failure and aborted in 
>>>>> it.
>>>>>
>>>>>
>>>>> Is there a way to parameterize a reusable post{} block I can import in
>>>>> all my pipelines? I'd like to be able to import it and pass it params as
>>>>> well (because while its *almost* the same it varies very slightly for
>>>>> different pipelines).
>>>>>
>>>>>
>>>>> Here is an example post block that is currently copy and pasted inside
>>>>> all my pipeline{}s
>>>>>
>>>>>
>>>>> post {
>>>>> success{
>>>>> script {
>>>>> // I'd like to be able to pass in values for param1 and param2
>>>>> someGroovyScript {
>>>>> param1 = 'blah1'
>>>>> param2 = 'blah2'
>>>>> }
>>>>> // maybe id want a conditional here that does something with 
>>>>> a passed in param
>>>>> if (param3 == 'blah3') {
>>>>> echo 'doing something'
>>>>> }
>>>>> }
>>>>> }
>>>>> unstable{
>>>>> ... you get the idea
>>>>> }
>>>>> aborted{
>>>>> ... you get the idea
>>>>> }
>>>>> failure{
>>>>> ... you get the idea
>>>>> }
>>>>> }
>>>>>
>>>>> --
>>> 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-use...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/aa1f5f13-a8c3-42b6-bccc-a35047f0c293%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/aa1f5f13-a8c3-42b6-bccc-a35047f0c293%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/5461e64c-d586-4151-bafd-ebd2076e550a%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/5461e64c-d586-4151-bafd-ebd2076e550a%40googlegroups.com?utm_medium=email_source=footer>
> .
> 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/CADgiF9JpX%2BKE2D6cL-42ad5ahVptsX-NKoL2CpUxXycncAzWjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I have a reusable “post” block for my jenkins pipelines?

2018-08-03 Thread red 888
wait there seems to be confusion about what i am asking for look at my SO 
post: 
https://stackoverflow.com/questions/51508234/can-i-have-a-reusable-post-block-for-my-jenkins-pipelines
 

I also ready use shared libs, all my pipelines are there. Between those 
several pipelines they all have a post block that is nearly identical. I 
want to reference a parameterized post block ONLY. My post block now is 
like 80 lines of code at the end of each pipeline thats nearly tthe same. 
even after moving most of the post block steps into separate groovy files 
(that are referenced in the post block) the whole post block is still large.

On Thursday, August 2, 2018 at 3:13:56 PM UTC-4, Jan Monterrubio wrote:
>
> We do this in our CI. Basically the shared library has some variable 
> parameters you can override and it lets you control what happens based on 
> those. I’ll see if I can scrounge up a sample later today.
>
> On Thu, Aug 2, 2018 at 11:04 red 888 > 
> wrote:
>
>> how does that work though? My pipelines are already in shared libraries. 
>> I want a shared post block specifically.
>>
>>
>> On Monday, July 30, 2018 at 7:33:21 AM UTC-4, Johan Abildskov wrote:
>>>
>>> You should be able to do this with Shared Libraries: 
>>> https://jenkins.io/doc/book/pipeline/shared-libraries/
>>>
>>> On Thursday, July 26, 2018 at 9:22:53 PM UTC+2, red 888 wrote:
>>>>
>>>> I have many jenkins pipelines for several different platforms but my 
>>>> "post{}" block for all those pipelines is pretty samey. And its quite 
>>>> large 
>>>> at this point because I include success,unstable,failure and aborted in it.
>>>>
>>>>
>>>> Is there a way to parameterize a reusable post{} block I can import in 
>>>> all my pipelines? I'd like to be able to import it and pass it params as 
>>>> well (because while its *almost* the same it varies very slightly for 
>>>> different pipelines).
>>>>
>>>>
>>>> Here is an example post block that is currently copy and pasted inside 
>>>> all my pipeline{}s
>>>>
>>>>
>>>> post {
>>>> success{
>>>> script {
>>>> // I'd like to be able to pass in values for param1 and param2
>>>> someGroovyScript {
>>>> param1 = 'blah1'
>>>> param2 = 'blah2'
>>>> }
>>>> // maybe id want a conditional here that does something with a 
>>>> passed in param
>>>> if (param3 == 'blah3') {
>>>> echo 'doing something'
>>>> }
>>>> }
>>>> }
>>>> unstable{
>>>> ... you get the idea
>>>> }
>>>> aborted{
>>>> ... you get the idea
>>>> }
>>>> failure{
>>>> ... you get the idea
>>>> }
>>>> }
>>>>
>>>> -- 
>> 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-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/aa1f5f13-a8c3-42b6-bccc-a35047f0c293%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/aa1f5f13-a8c3-42b6-bccc-a35047f0c293%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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/5461e64c-d586-4151-bafd-ebd2076e550a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I have a reusable “post” block for my jenkins pipelines?

2018-08-02 Thread Jan Monterrubio
We do this in our CI. Basically the shared library has some variable
parameters you can override and it lets you control what happens based on
those. I’ll see if I can scrounge up a sample later today.

On Thu, Aug 2, 2018 at 11:04 red 888  wrote:

> how does that work though? My pipelines are already in shared libraries. I
> want a shared post block specifically.
>
>
> On Monday, July 30, 2018 at 7:33:21 AM UTC-4, Johan Abildskov wrote:
>>
>> You should be able to do this with Shared Libraries:
>> https://jenkins.io/doc/book/pipeline/shared-libraries/
>>
>> On Thursday, July 26, 2018 at 9:22:53 PM UTC+2, red 888 wrote:
>>>
>>> I have many jenkins pipelines for several different platforms but my
>>> "post{}" block for all those pipelines is pretty samey. And its quite large
>>> at this point because I include success,unstable,failure and aborted in it.
>>>
>>>
>>> Is there a way to parameterize a reusable post{} block I can import in
>>> all my pipelines? I'd like to be able to import it and pass it params as
>>> well (because while its *almost* the same it varies very slightly for
>>> different pipelines).
>>>
>>>
>>> Here is an example post block that is currently copy and pasted inside
>>> all my pipeline{}s
>>>
>>>
>>> post {
>>> success{
>>> script {
>>> // I'd like to be able to pass in values for param1 and param2
>>> someGroovyScript {
>>> param1 = 'blah1'
>>> param2 = 'blah2'
>>> }
>>> // maybe id want a conditional here that does something with a 
>>> passed in param
>>> if (param3 == 'blah3') {
>>> echo 'doing something'
>>> }
>>> }
>>> }
>>> unstable{
>>> ... you get the idea
>>> }
>>> aborted{
>>> ... you get the idea
>>> }
>>> failure{
>>> ... you get the idea
>>> }
>>> }
>>>
>>> --
> 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/aa1f5f13-a8c3-42b6-bccc-a35047f0c293%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/CADgiF9JOQ6_MY_0Jv7FvhMe9yOQYABJqORnQRyJ%2BxhR%3DxqviWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.