Jenkinsfile 使用图像前缀的参数



是否可以在我的 Jenkinsfile 中使用参数作为我的 containerTemplate 图像前缀?

我在断开连接的环境中工作,并使用代理访问我的图像。 如果开发人员有一个希望部署到我的环境的 Jenkinsfile,他们需要指定映像前缀以在其 podTemplate 中使用我的代理。 可以想象,他们可能会将应用程序部署到映像前缀会更改的多个环境中。 要求贡献者维护多组适合在不同环境中部署的 Jenkinsfile 似乎有点过分了。我尝试在我的构建设置中设置一个字符串参数,但它似乎只在构建中使用,而不是在 containerTemplate 定义中使用。

下面是我试图完成的 Jenkinsfile 示例。 我希望能够传入 ${repo_url} 的值:

containerTemplate(name: 'min', image: '${repo_url}/rhel7-minimal', command: 'cat', ttyEnabled: true)
]) {
node('label') {
stage('Hello World') {
container('min') {
echo "HELLO WORLD"
}
} 
}
}

如果将管道配置为接受参数,则可以使用 ${params.parameter} 访问它们

最新更新