Search code examples
jenkinsgitlabjenkins-job-dsl

How can I set the secret token for gitlab plugin with Jenkins job dsl?


The documentation from the plugin site seems to be wrong: https://github.com/jenkinsci/gitlab-plugin

Example from job dsl documentation: https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.gitlabPush

In GitLabPushTrigger you can set secretToken but how can I set it via job dsl?

My current Job:

job('seed-job-v2') {

    description('Job that makes sure a service has a build pipeline available')

    triggers {
        gitlabPush {}
    }

    ...
}

Solution

  • Use the dynamic DSL:

    job('example') {
      triggers {
        gitlab {
          secretToken('foo')
        }
      }
    }
    

    The dynamic DSL supports almost all config options.