GitLab CI/CD variables ;GitLab CI/CD变量(翻译)

原文:《GitLab CI 变量》:https://docs.gitlab.com/ee/ci/variables/

凭个人理解+彩云小译结合来翻译,不是官方翻译,不保证准确,仅供参考

如有错处,欢迎留言指出,感谢指正!

GitLab CI/CD variables

GitLab CI 变量

CI/CD variables are a type of environment variable. You can use them to:

CI/CD 变量是环境变量的一种类型,你可以把它们用于:

Control the behavior of jobs and pipelines.
Store values you want to re-use.
Avoid hard-coding values in your .gitlab-ci.yml file.
You can override variable values manually for a specific pipeline, or have them prefilled in manual pipelines.

控制 jobs 和 pipelines 的行为。
保存你想要重复使用的值。
在你的 .gitlab-ci.yml 文件避免使用硬编码。
你可以手动为一个特殊的pipeline重写变量的值,或者在人工pipelines里预先填充变量的值。

Variable names are limited by the shell the runner uses to execute scripts. Each shell has its own set of reserved variable names.

变量名受限于shell这个执行脚本的运行程序。每个shell都有一组自己的保留变量名(我们不能用这些变量名来命名)

Predefined CI/CD variables

预置的CI/CD变量

GitLab CI/CD makes a set of predefined CI/CD variables available for use in pipeline configuration and job scripts. These variables contain information about the job, pipeline, and other values you might need when the pipeline is triggered or running.

GitLab CI/CD 预置了一些 CI/CD 变量,可用于pipeline 配置文件和job脚本。这些变量包括了一些关于job、pipeline的信息,以及在pipeline触发或运行时你可能会需要的其他值。

You can use predefined CI/CD variables in your .gitlab-ci.yml without declaring them first. For example:

在gitlab-ci.yml里,你不需要声明就可以使用这些预置的 CI/CD变量,例如:

job1:
  stage: test
  script:
    - echo "The job's stage is '$CI_JOB_STAGE'"

The script in this example outputs The job’s stage is ‘test’.

这个例子的脚本会输出“The job’s stage is ‘test’”

你可能感兴趣的:(翻译,gitlab,ci/cd,java)