gpt4 book ai didi

docker - Jenkins Pipeline是否可以编写/配置单独的Jenkins作业?

转载 作者:行者123 更新时间:2023-12-02 19:36:50 29 4
gpt4 key购买 nike

我有一个Jenkins管道,该管道构建docker镜像并用git hash标记它们。我还拥有另一个参数化的Jenkins管道,该管道采用了几个字符串/选择参数来部署docker镜像。我希望构建管道可以将一些字符串附加到部署管道的选择参数中,以便当用户运行部署管道时,会向他/她提供最近成功构建的Docker镜像列表供您选择。

有人知道怎么做吗?

最佳答案

一种方法是,您的第一项工作是使用最近建立的图像选项卡列表(每行一个)设置环境变量。
参见declarative pipeline environment directive

然后,在“Dynamic Parameter in Jenkinsfile?”之后,您可以使用类似以下的外部函数:

#!/bin/groovy

def envs = loadEnvs();

properties([
parameters([
choice(choices: envs, description: 'Please select an image tag', name: 'Env')
])
])

这应该足以建立一个选择参数列表。

Pipeline: How to manage user inputs ”(两周前,2017年5月10日)显示了替代命令,但在 Declarative Pipeline syntax中无效:

You have to use the input step to achieve it.
It will give you something like this :



stage 'promotion'
def userInput = input(
id: 'userInput', message: 'Let\'s promote?', parameters: [
[$class: 'TextParameterDefinition', defaultValue: 'uat', description: 'Environment', name: 'env'],
[$class: 'TextParameterDefinition', defaultValue: 'uat1', description: 'Target', name: 'target']
])
echo ("Env: "+userInput['env'])
echo ("Target: "+userInput['target'])

关于docker - Jenkins Pipeline是否可以编写/配置单独的Jenkins作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44125354/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com