Extend the context of another plugin?

99 views
Skip to first unread message

Dan Alvizu

unread,
Oct 22, 2015, 12:03:52 PM10/22/15
to job-dsl-plugin

Hi,


I am using the Job DSL plugin on my project. I have a proprietary plugin, part of which is

a provider of parameters for the parameterized-trigger plugin. This allows me to trigger

a deployment with properties specified by my plugin:


```

  public class MyCustomBuildParameters
      extends hudson.plugins.parameterizedtrigger.AbstractBuildParameters
  {

    // ...

    @Extension
    public static class DescriptorImpl extends Descriptor<AbstractBuildParameters>
    {

      // ...

    }

  }

```


This works great in the UI - I would like to be able to specify this somehow as part of a job DSL:


```

  job('example') {



    publishers {

      // ...

      downstreamParameterized{

        trigger('') {

           myCustomParameters()

        }

      }

    }

  }

```


However it's not clear to me from reading the wiki how this would be done:


https://github.com/jenkinsci/job-dsl-plugin/wiki/Extending-the-DSL


The context of downstreamParameterized() (javaposse.jobdsl.dsl.helpers.common.DownstreamTriggerParameterContext) is not marked as an ExtensibleContext, so I cannot simply add aContextExtension point and a method with @DslExtensionMethod, as I could if this were the PublisherContext.


Is there an example out there I can reference, or can someone please point me in the right direction?


Thanks!

Daniel Spilker

unread,
Oct 22, 2015, 2:36:15 PM10/22/15
to job-dsl...@googlegroups.com
Hi,

yes, DownstreamTriggerParameterContext should be an ExtensibleContext. Please file a ticket for this: https://issues.jenkins-ci.org/browse/JENKINS/component/16720/. Then I will try to fix it for the next release.

In the meantime you can use a configure block to add your custom parameters to job configs:
https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block

Regards,
Daniel

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/b5093592-e70c-4b6e-bfd6-79f81944fb60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Alvizu

unread,
Oct 22, 2015, 3:20:44 PM10/22/15
to job-dsl-plugin

Dan Alvizu

unread,
Oct 23, 2015, 4:26:21 PM10/23/15
to job-dsl-plugin
For future reference, I did the configure approach -- the closest component implementing configure() was project, so I ended up putting it at that level:

This didn't seem to want to update the XML when I had configured parameterizedTrigger as a publisher, it would instead override it and lose some of my settings. So I configured everything in a configure block:


job {

  // steps, scm, etc..
  publishers  {
    // ...
  }

  configure { project ->
    project / 'publishers' / 'hudson.plugins.parameterizedtrigger.BuildTrigger' {
        configs {
          'hudson.plugins.parameterizedtrigger.BuildTriggerConfig' {
            configs {
              'com.example.MyCustomBuildParameters' {
              }
            }
            projects(myProjectName)
            condition('SUCCESS')
Reply all
Reply to author
Forward
0 new messages