I need to set a Gcloud deployment flag with an environment variable that I set during runtime. The reason for this is that I am trying to version my cloud run services and if the parameter TAG_NAME comes in as ver1.0.0 or ver1.0.1 I only ever want it to be the variable ver1.
So long story short I want to be able to use
<code>_CUT_TAG=$(echo $TAG_NAME | cut -d '.' -f 1)
</code>
<code>_CUT_TAG=$(echo $TAG_NAME | cut -d '.' -f 1)
</code>
_CUT_TAG=$(echo $TAG_NAME | cut -d '.' -f 1)
In the script below to set the parameter
<code> --tag $_CUT_TAG
</code>
<code> --tag $_CUT_TAG
</code>
--tag $_CUT_TAG
But every time I try to set it the function fails. Here is the entire command:
<code> - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args:
- '-c'
- |
_CUT_TAG=$(echo $TAG_NAME | cut -d '.' -f 1)
gcloud beta run deploy my-service
--image gcr.io/$PROJECT_ID/account-service
--region us-central1
--tag $_CUT_TAG
</code>
<code> - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args:
- '-c'
- |
_CUT_TAG=$(echo $TAG_NAME | cut -d '.' -f 1)
gcloud beta run deploy my-service
--image gcr.io/$PROJECT_ID/account-service
--region us-central1
--tag $_CUT_TAG
</code>
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args:
- '-c'
- |
_CUT_TAG=$(echo $TAG_NAME | cut -d '.' -f 1)
gcloud beta run deploy my-service
--image gcr.io/$PROJECT_ID/account-service
--region us-central1
--tag $_CUT_TAG
And here is the error I am receiving
<code>ERROR: (gcloud.beta.run.deploy) argument --tag: expected one argument
</code>
<code>ERROR: (gcloud.beta.run.deploy) argument --tag: expected one argument
</code>
ERROR: (gcloud.beta.run.deploy) argument --tag: expected one argument
which is telling me that the parameter isnt getting set.