gpt4 book ai didi

jenkins - 有没有办法检查作业的 jenkins 输出,如果字符串存在则使作业成功,否则失败?

转载 作者:行者123 更新时间:2023-12-02 02:43:17 24 4
gpt4 key购买 nike

我有一个包含 2 个步骤的管道:

第一个正在执行错误的“构建”作业 - 项目名称不正确(test3 而不是 test)

第二步打印 1

现在这条管道有两个问题,

1) 第一阶段是绿色的,虽然作业失败了为此我创建了这个问题: how to fix - stageResult set to FAILURE but still get success in jenkins

2) 我希望能够读取构建作业并找到有错误的字符串:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\pipeline testing
[Pipeline] {
[Pipeline] stage
[Pipeline] { (1)
[Pipeline] catchError
[Pipeline] {
[Pipeline] build (Building build)
Scheduling project: build
Starting building: build #102
[Pipeline] }
ERROR: build #102 completed with status FAILURE (propagate: false to ignore)
[Pipeline] // catchError
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
...

如何添加到我的管道:如果你看到这一行:“收到 HTTP/400:错误请求,“找不到项目。”这是在构建(自由式)本身内部

使本阶段成功,否则使本阶段失败

这是现在的管道:

pipeline {
agent any
stages
{
stage('1')
{
steps
{
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE')
{
build job: 'build',parameters: [string(name:
'Project_Name', value: 'test3'),
string(name: 'Environment_Name', value: 'Dev_Env_1')]
}

}
}
stage('2')
{
steps
{
echo '1'
}
}
}
}

最佳答案

选题不错 JOHN SMITH。我也有类似的问题你试过这样处理吗?

try { stage('some-stage') { //do something } } catch (Exception e) { echo "Stage failed, but we continue" } try { stage("some-other-stage") { // do something } } catch (Exception e) { echo "Stage failed, but we still continue" }

关于jenkins - 有没有办法检查作业的 jenkins 输出,如果字符串存在则使作业成功,否则失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57753897/

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