[英]Check tag is correct version in GitLab-CI pipeline
When a new tag is created I want to validate in the pipeline configuration that the new tag version is correct and the same than python setup.py.创建新标签时,我想在管道配置中验证新标签版本是否正确且与 python setup.py 相同。 I added this script to the pipeline but looks like is not working.
我将此脚本添加到管道中,但看起来不起作用。
script:
- VERSION=$(python setup.py --version)
- if [ $CI_COMMIT_TAG != $VERSION ]; then
- echo "Tag does not match the correct version"
- exit 1; fi
You can't split bash if/then statements across multiple script array items in GitLab CI.您不能在 GitLab CI 中的多个脚本数组项之间拆分 bash if/then 语句。 You must either do it all in one line or use a multiline string for the array item.
您必须在一行中完成所有操作,或者对数组项使用多行字符串。
script:
- version=$(python setup.py --version)
- |
if [[ "$CI_COMMIT_TAG" != "${version}" ]]; then
echo "Tag '${CI_COMMIT_TAG}' does not match the expected version '${VERSION}'"
exit 1
fi
- echo "OK"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.