Jenkins DSL添加秘密文件

时间:2016-12-16 16:02:38

标签: jenkins jenkins-job-dsl

我想在我的工作中添加秘密文件,但我找不到Jenkis DSL中的哪个关键字,有什么建议吗?

enter image description here

在xml中它看起来像这样:

<project>
...
<properties>...</properties>
<scm class="hudson.scm.NullSCM"/>
<builders>...</builders>
<buildWrappers>
  <org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper plugin="credentials-binding@1.10">
     <bindings>
        <org.jenkinsci.plugins.credentialsbinding.impl.FileBinding>
            <credentialsId>my-keytab</credentialsId>
            <variable>KEYTAB</variable>
        </org.jenkinsci.plugins.credentialsbinding.impl.FileBinding>
     </bindings>
    </org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper>
</buildWrappers>
</project>

1 个答案:

答案 0 :(得分:2)

您可以在file上下文中使用credentialsBinding

job('example') {
  wrappers {
    credentialsBinding {
      file('KEYTAB', 'my-keytab')
    }
  }
}

有关详细信息,请参阅API Viewer