I'm having a problem when executing automatic pipelines (from a commit in a branch) with this code block below.
echo $GCLOUD_PROD > auth_base.json | base64 -d auth_base.json > auth.json | gcloud auth activate-service-account --key-file auth.json
It always fails. When a manually start it from GUI it works.
Can anyone help me?
Tks.
Hmm.
echo $GCLOUD_PROD > auth_base.json | base64 .....
I'm not understanding how this works anywhere...
The first io redirect `>` would redirect all stdout to that file, so only stderr would be passed through the pipe to base64 and subsequent commands.
Also, to get more accurate help, what is the purpose of the 2 auth files?
Typically I see base64 decoding of environment variables handled like this, with any subsequent commands broken to their own line to use the decoded file.
script:
- echo $GCLOUD_PROD | base64 -d > auth.json
- gcloud auth activate-service-account --key-file auth.json
Eddie,
It´s working (when started manually) in a bunch of projects. See the attached image.
That's because de subsequent commands do not need the stdout and/or stderr.
They are working with the file created.
I divided it into two files only to make more clear the process.
First, get the base64 env and create a file, after convert that base64 file to a plain text file.
And, so then, log into gcp.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, I see, so you're just using pipes to chain the commands? I've not seen that pattern.
Anyway, can you send a failure example? I see your working example is a deployment, is it possible the Variable is not available to your automatic runs? (which may not be specifying an environment to access environment specific variables?)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did not specify env for a specific environment. That is useful, can you point me a doc to do that?
Below is my script:
release/ecare-master:
- step:
name: Build image
script: # compila a imagem e sobe ela para o repositório de imagens
- echo $GCLOUD_PROD > auth_base.json | base64 -d auth_base.json > auth.json | gcloud auth activate-service-account --key-file auth.json
- export IMAGE_NAME=gcr.io/hcms-prod/hcms-salessurvey-frontend:$BITBUCKET_COMMIT
- docker build -t $IMAGE_NAME --build-arg REACT_APP_BASE_URL='' --build-arg REACT_APP_TOKEN_SECRET=hcmsjsonwebtokensecretapiPPRDO --build-arg REACT_APP_BASE_URL_SURVEY=/survey --build-arg REACT_APP_KIBANA_URL=https://1a97ebd98d4047208c895b2c2b2f3828.southamerica-east1.gcp.elastic-cloud.com:9243 .
- gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://gcr.io
- docker push $IMAGE_NAME
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Huh.
For the environment variables:
Deployment variables override both team and repository variables. Also variables with the same name can have different values for each deployment environment. For example, you could set a different $DEPLOYMENT_SECRET_KEY for each environment
https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-monitor-deployments/
For the error... I'm stumped!
base64 is throwing the error, not finding file. So my mind goes to the previous command, echo. Echo's simplicity has me wondering about the variable.
I personally would either debug locally or try to isolate cause with lots of debug statements to isolate cause.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.