Re: Plugin development : extension to add custom options in declarative pipeline

2018-05-18 Thread Robert Sandell
I think

 options {
 // Declare the Foo
 withFoo(fooParams)
 }

Should work as is. Have you tried it?

/B

2018-05-17 18:44 GMT+02:00 Bill Dennis :

> I am developing a Jenkins pipeline plugin that provides some custom block
> scoped steps something like this:
>
> withFoo( fooParams ) {
>// Some code block that uses the declared "Foo" thing
> }
>
>
> My *withFoo* step creates some object "Foo" that is made available in the
> code block to my other custom steps.
>
> I have all this sort of thing working with custom block-scoped steps and
> simple steps and it is going well in my declarative pipelines and providing
> the functionality I need.
>
> However the "foo" is only available in a pipeline code block in a single
> declarative stage and it won't be available in a post handler unless I
> re-declare it ( think).
>
> I am envisioning some scenarios where I want my "Foo" object to be
> available to the whole job in the pipeline context using something like
> "options" (or possibly at the stage options level).
>
> So I am looking at the possibility of some custom option like this:
>
> pipeline {
>
>  agent none
>
>  options {
>  // Declare the Foo
>  foo(fooParams)
>  }
>
>
>  // Rest of pipeline uses the Foo in stages or post sections
> }
>
>
> To give some context, the "Foo" is some sort of connection to a remote system 
> so it could be expensive to keep tearing it down and re-establishing it.
>
>
> Is there a way to provide custom options like this to have an object is 
> created and put in the pipeline context for the whole pipeline and can be 
> consumed by my other custom steps?
>
>
> I had a look at the existing Jenkins extension point documents and around 
> some plugins in GitHub but I cannot tell whether these options are generally 
> extendable in this way.
>
>
> Thanks for any suggestions or pointers anyone here may have!
>
>
> --Bill
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-dev/92d6270f-7da0-4aea-b7ba-5f41eb1be190%
> 40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Robert Sandell*
Software Engineer
CloudBees, Inc.
[image: CloudBees-Logo.png] 
E: rsand...@cloudbees.com
Twitter: robert_sandell

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CALzHZS1%3DRT1DujCDuu6H1PtbCpaCEPY%2BeaXL7%3DbeKeVaPybaiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Plugin development : extension to add custom options in declarative pipeline

2018-05-17 Thread Bill Dennis
I am developing a Jenkins pipeline plugin that provides some custom block 
scoped steps something like this:

withFoo( fooParams ) {
   // Some code block that uses the declared "Foo" thing
}


My *withFoo* step creates some object "Foo" that is made available in the 
code block to my other custom steps.

I have all this sort of thing working with custom block-scoped steps and 
simple steps and it is going well in my declarative pipelines and providing 
the functionality I need.

However the "foo" is only available in a pipeline code block in a single 
declarative stage and it won't be available in a post handler unless I 
re-declare it ( think).

I am envisioning some scenarios where I want my "Foo" object to be 
available to the whole job in the pipeline context using something like 
"options" (or possibly at the stage options level).

So I am looking at the possibility of some custom option like this:

pipeline {

 agent none

 options {
 // Declare the Foo
 foo(fooParams)
 }


 // Rest of pipeline uses the Foo in stages or post sections
}


To give some context, the "Foo" is some sort of connection to a remote system 
so it could be expensive to keep tearing it down and re-establishing it.


Is there a way to provide custom options like this to have an object is created 
and put in the pipeline context for the whole pipeline and can be consumed by 
my other custom steps?


I had a look at the existing Jenkins extension point documents and around some 
plugins in GitHub but I cannot tell whether these options are generally 
extendable in this way.


Thanks for any suggestions or pointers anyone here may have!


--Bill

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/92d6270f-7da0-4aea-b7ba-5f41eb1be190%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.