【问题标题】:Jenkins job DSL plugin - hidden parameterJenkins 工作 DSL 插件 - 隐藏参数
【发布时间】:2017-09-04 14:07:10
【问题描述】:

我正在使用 Jenkins hidden parameter plugin,但我找不到在 DSL 中编写它的语法,就像我使用其他参数所做的那样。

例如: https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.BuildParametersContext.activeChoiceParam

有没有办法在DSL中体现隐藏参数

【问题讨论】:

    标签: jenkins jenkins-plugins jenkins-pipeline jenkins-job-dsl


    【解决方案1】:

    Job DSL 没有对 Hidden Parameter 插件的内置支持,因此 API 查看器中没有提到它。但是Automatically Generated DSL支持:

    job('example') {
      parameters {
        wHideParameterDefinition {
          name('FOO')
          defaultValue('bar')
          description('lorem ipsum')
        } 
      }
    }
    

    【讨论】:

    • 这似乎比我的回答更准确。 +1
    【解决方案2】:

    在使用declarative pipeline syntax(在jenkinsci/pipeline-model-definition-plugin 中描述)之前,您会使用:

    但对于 pure DSL pipeline syntax,尚不支持此功能(2017 年 4 月)。

    最后一个问题虽然指出JENKINS-29922 (Promote delegates of metasteps to top-level functions, deprecate $class)并添加the comment

    JENKINS-29922 已实现,因此假设为每种凭据类型定义了@Symbol,并且凭据步骤标记为 metaStep,您可以更简单地编写:

    usernamePassword id: 'hipchat-login', username: 'bob', password: 'abc/def+GHI0123='
    hipchat server: …, message: …, credentialsId: 'hipchat-login'
    

    甚至允许生成 id,并从步骤中返回它:

    hipchat server: …, message: …, credentialsId: usernamePassword(username: 'bob', password: 'abc/def+GHI0123=')
    

    虽然这是加密的,但并不完全“隐藏”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-18
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多