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 <fakemai...@gmail.com <javascript:>> 
> 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 <javascript:>.
>> 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&utm_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.

Reply via email to