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 <fakemailred...@gmail.com> 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 > <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/CADgiF9JOQ6_MY_0Jv7FvhMe9yOQYABJqORnQRyJ%2BxhR%3DxqviWg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.