如何在 Jenkins 中创建一个包含参数和主体的共享库?
How can I create a shared library in Jenkins with both arguments and a body?
基本上我想在 Jenkins 中创建一个共享库,它会变成:
kPod(label: label){
body
}
进入:
podTemplate(label: label, //use argument as label
containers: [containerTemplate(name: 'jnlp', image: 'someImage', args: '${computer.jnlpmac} ${computer.name}')],
volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {
//put body here
}
然而,我看到的所有示例都允许您访问参数或正文,但不能同时访问两者。该文档也没有提及它:https://jenkins.io/doc/book/pipeline/shared-libraries/
但这显然是可能的,因为 podTemplate 步骤本身就是我想要的。
大声笑,我只需要将其添加为参数即可:
def call(config, body) {
// config is a map of the parameters
}
基本上我想在 Jenkins 中创建一个共享库,它会变成:
kPod(label: label){
body
}
进入:
podTemplate(label: label, //use argument as label
containers: [containerTemplate(name: 'jnlp', image: 'someImage', args: '${computer.jnlpmac} ${computer.name}')],
volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {
//put body here
}
然而,我看到的所有示例都允许您访问参数或正文,但不能同时访问两者。该文档也没有提及它:https://jenkins.io/doc/book/pipeline/shared-libraries/
但这显然是可能的,因为 podTemplate 步骤本身就是我想要的。
大声笑,我只需要将其添加为参数即可:
def call(config, body) {
// config is a map of the parameters
}