Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47030

job-dsl-plugin missing secretToken option for gitlab-plugin

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • job-dsl-plugin
    • None
    • Jenkins Enterprise 2.60.2.2
      job-dsl-plugin 1.65
      gitlab-plugin 1.4.8

        [JENKINS-47030] job-dsl-plugin missing secretToken option for gitlab-plugin

        Owen Mehegan added a comment -

        Looks like a Job DSL issue, not a GitLab Plugin issue.

        Owen Mehegan added a comment - Looks like a Job DSL issue, not a GitLab Plugin issue.

        All options are supported by the Automatically Generated DSL:

        job(String name) {
          triggers {
            gitlab {
              secretToken(String value)
            }
          }
        }
        

        Daniel Spilker added a comment - All options are supported by the Automatically Generated DSL : job( String name) { triggers { gitlab { secretToken( String value) } } }

        Hi, I disagree that this is not a defect. If I use the suggested function, then I have to define all values, since the Automatically Generated DSL has labeled all parameters as required, while the gitlab trigger allows for parameter defaults.

        Furthermore, if the answer is going to be "use gitlab triggers", then what is the purpose of having the gitlabPush trigger as well?

        Michael Griffin added a comment - Hi, I disagree that this is not a defect. If I use the suggested function, then I have to define all values, since the Automatically Generated DSL has labeled all parameters as required, while the gitlab trigger allows for parameter defaults. Furthermore, if the answer is going to be "use gitlab triggers", then what is the purpose of having the gitlabPush trigger as well?

        mgriffin gitlabPush trigger exists for backwards compatibility.

        Job DSL will not provide built-in support for every config option of all of the 1000+ Jenkins plugins. It's not possible to keep up with the changes in all plugins. The configure block has been available since v1.0 to allow generating arbitrary config options that are not available in the built-in DSL. The Automatically Generated DSL has been added to provide an alternative to configure blocks with a nicer syntax. But plugins have to provide the runtime metadata to be able to generate the syntax at runtime.

        In case of the GitLab plugin, the provided metadata is not correct. The plugin has marked all options as required (@DataBoundConstructor vs @DataBoundSetter). That should be fixed in the GitLab plugin. So please report an issue for that plugin and link to this issue.

        The following snippet shows how to use a configure block to add the option.

        job('example') {
            triggers {
                gitlabPush {
                }
            }
            configure {
                it / triggers / 'com.dabsquared.gitlabjenkins.GitLabPushTrigger' << secretToken('SECRET')
            }
        }
        

        Daniel Spilker added a comment - mgriffin gitlabPush trigger exists for backwards compatibility. Job DSL will not provide built-in support for every config option of all of the 1000+ Jenkins plugins. It's not possible to keep up with the changes in all plugins. The configure block has been available since v1.0 to allow generating arbitrary config options that are not available in the built-in DSL. The Automatically Generated DSL has been added to provide an alternative to configure blocks with a nicer syntax. But plugins have to provide the runtime metadata to be able to generate the syntax at runtime. In case of the GitLab plugin, the provided metadata is not correct. The plugin has marked all options as required ( @DataBoundConstructor vs @DataBoundSetter ). That should be fixed in the GitLab plugin. So please report an issue for that plugin and link to this issue. The following snippet shows how to use a configure block to add the option. job( 'example' ) { triggers { gitlabPush { } } configure { it / triggers / 'com.dabsquared.gitlabjenkins.GitLabPushTrigger' << secretToken( 'SECRET' ) } }

        Thank you for the explanation. After searching the gitlab-plugin repo, it appears as though there was already an issue opened (https://github.com/jenkinsci/gitlab-plugin/issues/613), with an associated pull request (https://github.com/jenkinsci/gitlab-plugin/pull/616).

        Michael Griffin added a comment - Thank you for the explanation. After searching the gitlab-plugin repo, it appears as though there was already an issue opened ( https://github.com/jenkinsci/gitlab-plugin/issues/613 ), with an associated pull request ( https://github.com/jenkinsci/gitlab-plugin/pull/616 ).

          daspilker Daniel Spilker
          mgriffin Michael Griffin
          Votes:
          0 Vote for this issue
          Watchers:
          3 Start watching this issue

            Created:
            Updated:
            Resolved: