Reputation: 61
I am trying to create an environment variable in my cloud build job named "MERGE_COMMIT_SHA". I am using this in my deployment pipeline in Spinnaker.
I create the variable from a curl command, this is working. I am then able to echo the variable successfully also.
steps:
- name: gcr.io/cloud-builders/curl
entrypoint: bash
args:
- "-c"
- |
apt-get update -y
apt-get install -y jq
export MERGE_COMMIT_SHA=$$(curl -u user:$$GITHUB_TOKEN https://api.github.com/repos/ORG/REPO/pulls/$_PR_NUMBER | jq -r '.merge_commit_sha')
echo "The commit sha is" $$MERGE_COMMIT_SHA
printenv
secretEnv:
- GITHUB_TOKEN
options:
env:
- 'MERGE_COMMIT_SHA=$$MERGE_COMMIT_SHA'
availableSecrets:
secretManager:
- versionName: projects/project/secrets/GITHUB_TOKEN/versions/1
env: 'GITHUB_TOKEN'
When I printenv in the job I see:
MERGE_COMMIT_SHA=MY Correct SHA
In the execution details of the job though, I see this:
Environment variables
MERGE_COMMIT_SHA $MERGE_COMMIT_SHA
And in the streaming to pub/sub which is where I am trying to get this variable to pass to, I see this:
"env": ["MERGE_COMMIT_SHA\u003d$MERGE_COMMIT_SHA"],
Am I doing something wrong on this? Or maybe there is a better way to do this?
The end goal of this is to pass the variable value that I create to spinnaker so that I can use it in my deployment jobs.
Upvotes: 0
Views: 653