【问题标题】:How can I set the secret token for gitlab plugin with Jenkins job dsl?如何使用 Jenkins job dsl 为 gitlab 插件设置秘密令牌?
【发布时间】:2018-08-15 11:41:14
【问题描述】:

插件站点的文档似乎有误:https://github.com/jenkinsci/gitlab-plugin

来自工作 dsl 文档的示例:https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.gitlabPush

GitLabPushTrigger 中,您可以设置secretToken,但如何通过作业 dsl 进行设置?

我现在的工作:

job('seed-job-v2') {

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

    triggers {
        gitlabPush {}
    }

    ...
}

【问题讨论】:

    标签: jenkins gitlab jenkins-job-dsl


    【解决方案1】:

    使用dynamic DSL

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

    动态 DSL 支持几乎所有的配置选项。

    【讨论】:

      【解决方案2】:

      替代方案是这样的

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

      【讨论】:

        【解决方案3】:

        pipelineTriggers 对此有直接支持,您只能在 jenkins 服务器的实时 API 查看器中查看。

        参考

        https://stackoverflow.com/a/66111017/1606098

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-02-06
          • 1970-01-01
          • 1970-01-01
          • 2016-10-20
          • 2022-09-23
          • 2016-02-20
          相关资源
          最近更新 更多