当我这样做时:
openpyxl
这只是失败,因为即使没有手动启动job1:
stage: build
when: manual
script:
- daddaa
job1_deploy:
stage: deploy
dependencies: [job1]
script:
- do things to deploy
,也启动了job1_deploy
。
是否有正确的方法来配置手动启动并传递job1
时自动启动的job1_deploy
?
答案 0 :(得分:1)
我打开了此错误报告:https://gitlab.com/gitlab-org/gitlab/issues/32552,别忘了投票。
作为一种解决方法,它不能解决问题,但至少可以向开发人员解释该问题,因此请执行以下操作:
job1
写一个额外的文件,例如“ testResult.txt”,其中包含“成功”或“失败”,具体取决于作业状态。job1
在文件中列出了该文件job1_deploy
,然后在before_script
中检查该文件是否存在,如果不存在,则说明问题并导致工作失败。 以下是我们使用的python脚本的摘录。
nightly
和deploy
。IGNORE_NIGHTLY_TEST
,可以在手动运行之前对其进行设置。我没有从摘录中删除这些行,也许对您有用。 # Hidden knowledge: you can ignore the test check
# by defining environment variable IGNORE_NIGHTLY_TEST
ignoreTest = "IGNORE_NIGHTLY_TEST" in os.environ
try:
content = open('testResult.txt', 'r').readline()
except (OSError, IOError) as e:
print("-" * 100)
if ignoreTest:
print(" Nightly tests did not run, but allow deployment due to environment variable IGNORE_NIGHTLY_TEST")
else:
print(" Nightly tests did not run, you have to start them MANUALLY before deployment is possible."
+ "\n Go back to this pipeline's overview and press play for nightlytest."
+ "\n This is a Gitlab bug: https://gitlab.com/gitlab-org/gitlab/issues/32552")
print("-" * 100)
sys.exit(0 if ignoreTest else 1)
if content != 'success':
print("+" * 100)
if ignoreTest:
print(" Nightly tests ran unsuccessfully, but allow deployment due to environment variable IGNORE_NIGHTLY_TEST")
else:
print(" Nightly tests ran but they were unsuccessful. Cannot deploy")
print("+" * 100)
sys.exit(0 if ignoreTest else 1)
答案 1 :(得分:0)
听起来好像您希望job1
是一项阻止手动操作。来自documentation:
如果要进行手动操作阻止,则必须添加 allow_failure:.gitlab-ci.yml中作业的定义为false。
因此,在您的情况下,这应该可以解决问题:
job1:
stage: build
when: manual
allow_failure: false
script:
- daddaa
job1_deploy:
stage: deploy
dependencies: [job1]
script:
- do things to deploy