简体   繁体   English

当变量在文件中时,如何使 Gitlab CI 不应用变量

[英]How to make Gitlab CI not apply variable when the variable is in file

I have created a GitLab pipeline and predefined variable (type file).我创建了一个 GitLab 管道和预定义变量(类型文件)。 That file contains a variable ${myVar} that should not has to be applied before some steps of the job.该文件包含一个变量${myVar} ,不应在作业的某些步骤之前应用该变量。 I found that when I open that file using cat , the ${myVar} disappeared.我发现当我使用cat打开该文件时, ${myVar}消失了。 Looks like it was applied but with an empty string since its content has not yet been generated.看起来它已被应用但带有一个空字符串,因为它的内容尚未生成。

Question: how to tell GitLab CI to ignore variables in the variable file问题:如何告诉GitLab CI忽略变量文件中的变量

The issue is fixed.问题已解决。 All you need to do is to add one more $ sign before the variable.您需要做的就是在变量前添加一个$符号。 Hence instead of ${myVar} you need to specify $${myVar} in this case GitLab CI will not apply the variable因此,在这种情况下,您需要指定$${myVar}而不是${myVar} GitLab CI 将不会应用该变量

As of Gitlab 13.7 you can disable variable expansion for the variable (enabled by default).从 Gitlab 13.7 开始,您可以禁用变量的变量扩展(默认情况下启用)。 See:看:

https://gitlab.nposervices.com/help/ci/variables/index#expand-cicd-variables https://gitlab.nposervices.com/help/ci/variables/index#expand-cicd-variables

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM