使用 Kubernetes 和 Jenkins 实现持续交付中的手动审批
Implementation of Manual Approval in Continuous Delivery using Kubernetes and Jenkins
目前我正在尝试使用 Kubernetes 和 Jenkins 实现持续交付和部署的示例。我已经成功地实施了持续部署。自动地,我的 REST API 正在通过 Jenkins 部署到我的 Kubernetes 集群。 test 和 prod 命名空间都在部署中。
现在我正在尝试通过在发布到 prod 名称空间之前进行手动用户批准来实现持续交付。意味着通过在测试和生产环境之间实现一次切换来实现手动批准。
为了更清楚起见,我在此处添加了我在探索时获得的屏幕截图,
持续交付和持续部署在手动审批方面的差异
这里我的困惑是,当我实施交付时,如何添加用户交互?我是否需要更改 deployment.yaml
或 service.yaml
中的任何参数?或者,当我在 Jenkins UI 中创建 Jenkins 管道作业时,我是否需要更改任何内容?
我是持续交付方面的新手。任何人都可以建议任何文档或教程或任何探索方法吗?
我们在 Jenkins 中使用共享库。我们将暂停管道 1 天,并使用 link 将邮件发送到 AD 中提及的批准 DL。如果不及时批准,我们将终止部署。
批准必须使用 link 登录 jenkins 才能批准部署。 (我们考虑过直接批准 link 但这是一个安全风险。)
timeout(time: 1, unit: "DAY")
{
log("Send an email to approvers@example.net with link)
sendEmail()
def inputResult = input (
id: "123",
message: "I approve this deployment",
)
}
您可以使用 Jenkins Input Step 来做这样的事情。输入步骤加上 try/catch
将使您能够很好地控制作业的 success/failure。
example below is from CloudBees support 门户并使用输入框,捕获输入并使用该输入值设置当前构建的success/failure
def userInput
try {
userInput = input(
id: 'Proceed1', message: 'Was this successful?', parameters: [
[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']
])
} catch(err) { // input false
def user = err.getCauses()[0].getUser()
userInput = false
echo "Aborted by: [${user}]"
}
node {
if (userInput == true) {
// do something
echo "this was successful"
} else {
// do something else
echo "this was not successful"
currentBuild.result = 'FAILURE'
}
}
目前我正在尝试使用 Kubernetes 和 Jenkins 实现持续交付和部署的示例。我已经成功地实施了持续部署。自动地,我的 REST API 正在通过 Jenkins 部署到我的 Kubernetes 集群。 test 和 prod 命名空间都在部署中。
现在我正在尝试通过在发布到 prod 名称空间之前进行手动用户批准来实现持续交付。意味着通过在测试和生产环境之间实现一次切换来实现手动批准。
为了更清楚起见,我在此处添加了我在探索时获得的屏幕截图,
持续交付和持续部署在手动审批方面的差异
这里我的困惑是,当我实施交付时,如何添加用户交互?我是否需要更改 deployment.yaml
或 service.yaml
中的任何参数?或者,当我在 Jenkins UI 中创建 Jenkins 管道作业时,我是否需要更改任何内容?
我是持续交付方面的新手。任何人都可以建议任何文档或教程或任何探索方法吗?
我们在 Jenkins 中使用共享库。我们将暂停管道 1 天,并使用 link 将邮件发送到 AD 中提及的批准 DL。如果不及时批准,我们将终止部署。
批准必须使用 link 登录 jenkins 才能批准部署。 (我们考虑过直接批准 link 但这是一个安全风险。)
timeout(time: 1, unit: "DAY")
{
log("Send an email to approvers@example.net with link)
sendEmail()
def inputResult = input (
id: "123",
message: "I approve this deployment",
)
}
您可以使用 Jenkins Input Step 来做这样的事情。输入步骤加上 try/catch
将使您能够很好地控制作业的 success/failure。
example below is from CloudBees support 门户并使用输入框,捕获输入并使用该输入值设置当前构建的success/failure
def userInput
try {
userInput = input(
id: 'Proceed1', message: 'Was this successful?', parameters: [
[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']
])
} catch(err) { // input false
def user = err.getCauses()[0].getUser()
userInput = false
echo "Aborted by: [${user}]"
}
node {
if (userInput == true) {
// do something
echo "this was successful"
} else {
// do something else
echo "this was not successful"
currentBuild.result = 'FAILURE'
}
}