通过bash命令设置GitLab环境变量

时间:2017-02-16 18:32:00

标签: bash yaml gitlab

因此。我正在使用GitLab,在我的.gitlab-ci.yml文件中,我有以下内容:

variables:
    CONTAINER_NAME: $CI_BUILD_REF_NAME | tr / -

$CI_BUILD_REF_NAME基本上读取了分支名称,在我的情况下是development/karl。我试图将变量名称CONTAINER_NAME设置为development-karl

当我回显变量时似乎没有工作,如下所示:

$ echo $CONTAINER_NAME
development/karl | tr / -

我在期待:

$ echo $CONTAINER_NAME
development-karl

我也试过了:

variables:
    CONTAINER_NAME: $( echo "$CI_BUILD_REF_NAME" | tr / - )
    CONTAINER_NAME_2: $( tr / - <<<"$CI_BUILD_REF_NAME" )
    CONTAINER_NAME_3: "${CI_BUILD_REF_NAME////-}"

//.. more script stuff

script:
  - echo $CONTAINER_NAME
  - echo $CONTAINER_NAME_2
  - echo $CONTAINER_NAME_3

得到了:

Successfully extracted cache
$ echo $CONTAINER_NAME
( echo "development/karl" | tr / - )
$ echo $CONTAINER_NAME_2
( tr / - <<<"development/karl" )
$ echo $CONTAINER_NAME_3

$ npm install

0 个答案:

没有答案