我有一个GitLab管道,在一个容器中运行一些Ansible剧本。最后,我想运行一些测试,以确保一切都正确配置,例如:
- name: Get the Frobzy value
raw: "frobzy -x foobar"
register: frobzy_val
changed_when: false
- name: Check that Frobzy is valid
assert:
that:
- frobzy_val.stdout is match "oogah"
fail_msg: "bad frobzy"
ignore_errors: true # see comments
- name: Get the Blobzy value
raw: "blobzy -y barfoo"
register: blobzy_val
changed_when: false
- name: Check that Blobzy is valid
assert:
that:
- blobzy_val.stdout is match "warra"
fail_msg: "bad blobzy"
ignore_errors: true # see comments
这一切都经过了很好的配置,因此我得到了一个JUnit报告,它显示在我的GitLab管道结果中。
问题是,假设这两个测试都失败了。如果我查看我的管道的测试结果,它正确地显示测试失败了。然而管道本身却标记为已通过!如果我没有仔细查看测试结果,我会认为一切都很顺利,并合并了一些可能损坏的代码。
管道被标记为成功的原因是因为那些ignore_errors: true
设置。它注册了一个错误,但是遵循了这样做不应该使管道失败的指令。但是如果我设置ignore_errors: false
(这是默认行为),则一旦Frobzy测试失败,流水线将中止并显示Frobzy测试失败,但由于它从未运行Blobzy测试,我不知道Blobzy也会失败。
基本上,我想要一种方法来运行我的所有AnsibleAssert,即使其中一些失败;我希望看到我的管道中的 * 所有 * 测试结果,并且如果 * 任何 * 测试失败,我希望管道 * 失败 *。
我该怎么做?
2条答案
按热度按时间xv8emn3q1#
failed
变量设置为true
。ylamdve62#