修改gitlab中的变量值-ci.yml
Modifiy variable values in gitlab-ci.yml
假设
CI_COMMIT_BRANCH=abc/xyz
和.gitlab-ci.yml
variables:
VAR: ${CI_COMMIT_BRANCH}
有没有办法把.gitlab-ci.yml中CI_COMMIT_BRANCH的值去掉'abc/',让VAR的值最终变成'xyz'?
检查 issue 27921 中描述的解决方法是否可行:
variables:
CI_SHORT_COMMIT_SHA: '$${CI_COMMIT_SHA:0:8}'
FOO_BAR: '$${FOO}-$${BAR}'
before_script:
- eval export CI_SHORT_COMMIT_SHA=${CI_SHORT_COMMIT_SHA}
- eval export FOO_BAR=${FOO_BAR}
test:
script:
- echo ${CI_SHORT_COMMIT_SHA}
- echo ${FOO_BAR}
你的情况:
variables:
VAR: $$(eval echo "${CI_COMMIT_BRANCH}" | sed "s,^.\+\?/,," )
before_script:
- eval export VAR=${VAR}
test:
script:
- echo ${VAR}
假设
CI_COMMIT_BRANCH=abc/xyz
和.gitlab-ci.yml
variables:
VAR: ${CI_COMMIT_BRANCH}
有没有办法把.gitlab-ci.yml中CI_COMMIT_BRANCH的值去掉'abc/',让VAR的值最终变成'xyz'?
检查 issue 27921 中描述的解决方法是否可行:
variables:
CI_SHORT_COMMIT_SHA: '$${CI_COMMIT_SHA:0:8}'
FOO_BAR: '$${FOO}-$${BAR}'
before_script:
- eval export CI_SHORT_COMMIT_SHA=${CI_SHORT_COMMIT_SHA}
- eval export FOO_BAR=${FOO_BAR}
test:
script:
- echo ${CI_SHORT_COMMIT_SHA}
- echo ${FOO_BAR}
你的情况:
variables:
VAR: $$(eval echo "${CI_COMMIT_BRANCH}" | sed "s,^.\+\?/,," )
before_script:
- eval export VAR=${VAR}
test:
script:
- echo ${VAR}