Google cloud platform CloudBuild Bash风格的字符串操作
我需要从TAG_NAME默认变量中提取一个字符串。但我没法让它工作Google cloud platform CloudBuild Bash风格的字符串操作,google-cloud-platform,google-cloud-build,Google Cloud Platform,Google Cloud Build,我需要从TAG_NAME默认变量中提取一个字符串。但我没法让它工作 - name: 'gcr.io/cloud-builders/git' id: find-folder-name dir: ${_DIR} entrypoint: 'bash' args: - '-c' - | if [ ${_STRATEGY} = "tag" ]; echo "tag name " $TAG_NAME; echo ${TAG_
- name: 'gcr.io/cloud-builders/git'
id: find-folder-name
dir: ${_DIR}
entrypoint: 'bash'
args:
- '-c'
- |
if [ ${_STRATEGY} = "tag" ]; echo "tag name " $TAG_NAME; echo ${TAG_NAME%\.np\.v\.*};fi
volumes:
- name: 'ssh'
path: /root/.ssh
secretEnv: ['GCLOUD_SERVICE_KEY']
如果我只在gitbash本地运行正则表达式,它的工作就非常好。
输出是follow,我希望它也会打印“test”,但它是空的。这是输出
tag name test.np.v.1.1.7
通过分配给变量进行修复
release=$TAG_NAME;echo ${release%\.np\.v\.*}
请把你的答案标记为正确。