分支名习惯用feature/xxxxx等格式,每次在CI的build 镜像编译阶段总是报如下错误:
invalid argument "hub.docker.org/xxxx/xxxx:feature/xxxx/xxxx" for "-t, --tag" flag: invalid reference format
查看docker build和docker tag文档,确定tag格式,给build的stage阶段加上only字段限制
docker tag | Docker Documentation
Build:
image: hub.docker.org/xxxx/xxxx:1.16 # 可以使用image指定该步骤使用特定的镜像来运行
stage: Build
only:
# https://docs.docker.com/engine/reference/commandline/tag/
# A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes.
# A tag name may not start with a period or a dash and may contain a maximum of 128 characters.
- /^[\w_][\w\-_\\.]{0,128}$/
except:
- /.*[\/\\].*/
script:
- echo ${CI_COMMIT_REF_NAME}
可以在正则表达式网站(gitlab ci使用ruby正则表达式验证)进行在线验证Rubular: a Ruby regular expression editor