• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • implied-labels-plugin
    • None
    • Jenkins v2.346.3

      I'd like to be able to configure the `implied-labels` plugin using the JCasC plugin. However, the current implementation doesn't seem to support that.

          [JENKINS-69663] Support JCasC in the implied labels plugin

          Mark Waite added a comment -

          Thanks for the enhancement request. I agree that it would be much better if the configuration of the implied labels plugin could be described in JCasC.

          My current workaround is to store the XML implied labels definition file. See an example in https://github.com/MarkEWaite/docker-lfs/blob/lts-with-plugins/ref/org.jenkinsci.plugins.impliedlabels.Config.xml

          Mark Waite added a comment - Thanks for the enhancement request. I agree that it would be much better if the configuration of the implied labels plugin could be described in JCasC. My current workaround is to store the XML implied labels definition file. See an example in https://github.com/MarkEWaite/docker-lfs/blob/lts-with-plugins/ref/org.jenkinsci.plugins.impliedlabels.Config.xml

          Mike Delaney added a comment -

          markewaite Thanks for the workaround.

          Do you know if we can use the groovy init.d hooks to configure this plugin?

          Mike Delaney added a comment - markewaite Thanks for the workaround. Do you know if we can use the groovy init.d hooks to configure this plugin?

          Mark Waite added a comment -

          I've never tried to use init.d hooks to configure the plugin. I find it much easier to copy the XML file from my installation than to wrestle with finding the right API's inside the plugin to call from a groovy init.d hook. I like groovy a lot, but have never spent the time to configure implied labels with it.

          Mark Waite added a comment - I've never tried to use init.d hooks to configure the plugin. I find it much easier to copy the XML file from my installation than to wrestle with finding the right API's inside the plugin to call from a groovy init.d hook. I like groovy a lot, but have never spent the time to configure implied labels with it.

          Mike Delaney added a comment -

          That's fair. For my use case, we were already using the `groovy init.d hooks` so that fits better into our current setup.

          For what it's worth, I was able to use the `init.groovy.d` hook and use something like (simplified config):

          import jenkins.*;
          import jenkins.model.*;
          import org.jenkinsci.plugins.impliedlabels.Implication;
          
          impliedLabels = Jenkins.instance.getExtensionList(org.jenkinsci.plugins.impliedlabels.Config.class)[0]
          
          Collection<Implication> settings = [
            new Implication('win2012r2 && docker', 'win-docker'),
            new Implication('linux && docker', 'linux-docker')
          ]
          
          impliedLabels.implications(settings)
          

          For full disclosure, this has not been extensively tested so there may be a little peril.

          Mike Delaney added a comment - That's fair. For my use case, we were already using the `groovy init.d hooks` so that fits better into our current setup. For what it's worth, I was able to use the `init.groovy.d` hook and use something like (simplified config): import jenkins.*; import jenkins.model.*; import org.jenkinsci.plugins.impliedlabels.Implication; impliedLabels = Jenkins.instance.getExtensionList(org.jenkinsci.plugins.impliedlabels.Config.class)[0] Collection<Implication> settings = [ new Implication( 'win2012r2 && docker' , 'win-docker' ), new Implication( 'linux && docker' , 'linux-docker' ) ] impliedLabels.implications(settings) For full disclosure, this has not been extensively tested so there may be a little peril.

          Hi,

          Same request here.

          I'm not sure about the effort here (maybe missing symbols ?)

          Valentin Delaye added a comment - Hi, Same request here. I'm not sure about the effort here (maybe missing symbols ?)

          Valentin Delaye added a comment - I've just open a PR here : https://github.com/jenkinsci/implied-labels-plugin/pull/145

          Mark Waite added a comment -

          I'm now managing my implied labels definition with the pull request. Refer to the configuration file for the definition I am using today. I'm not ready to merge it yet, but can confirm that it is working in my interactive tests.

          Mark Waite added a comment - I'm now managing my implied labels definition with the pull request . Refer to the configuration file for the definition I am using today. I'm not ready to merge it yet, but can confirm that it is working in my interactive tests.

            jonesbusy Valentin Delaye
            mdelaney Mike Delaney
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: