Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
继承Gitlab预定义变量_Gitlab_Devops_Gitlab Ci_Predefined Variables - Fatal编程技术网

继承Gitlab预定义变量

继承Gitlab预定义变量,gitlab,devops,gitlab-ci,predefined-variables,Gitlab,Devops,Gitlab Ci,Predefined Variables,我有一个Gitlab CI,如下所示。我的目的:当构建阶段失败时,将触发notify阶段并向收件人发送电子邮件 build website: stage: build script: ... send email: stage: notify when: on_failure script: #send email to recipients 但在我的内容电子邮件中,我想使用一些预定义的变量来表示工作失败。示例:“作业$CI\U作业\U阶段管道故障中的作业$CI\U作业\

我有一个Gitlab CI,如下所示。我的目的:当构建阶段失败时,将触发notify阶段并向收件人发送电子邮件

build website:
  stage: build
  script: ...

send email:
  stage: notify
  when: on_failure
  script: #send email to recipients

但在我的内容电子邮件中,我想使用一些预定义的变量来表示工作失败。示例:“作业$CI\U作业\U阶段管道故障中的作业$CI\U作业\U名称”。如何从stage notify将变量引用到stage build。请帮帮我,兄弟。谢谢。

在GitLab中,工作是独立的。如果您想在作业之间共享一些上下文,您可以使用工件

build website:
  stage: build
  script:
    - # build website
    - # save whatever you want in log.txt
  artifacts:
    paths:
      - ./log.txt

send email:
  stage: notify
  when: on_failure
  script: 
    - export CI_JOB_NAME = $(cat log.txt)
    - #send email to recipients