skip to Main Content

I have a build pipline defined as such:

- name: 'ubuntu'
  env:
   - 'URL="$$_URL/movies"'
  secretEnv: ['_URL']
  script: 'echo URL'
availableSecrets:
 secretManager:
  - versionName: projects/$PROJECT_ID/secrets/url/versions/latest
    env: '_URL'

This produces $_URL/movies and I’d like to have my value substituted in that string in env. If I use single $ I get error with no default substitution called _URL.

2

Answers


  1. Chosen as BEST ANSWER

    I resolved my problem in the end in quite an easy way.

    Using variables from secrets in clauses other than args/script is not supported, so I used only script to define variables and do computation. I also took into account the mistake pointed out by guillaume blaquiere.

    So the final yaml looks something like this:

    - name: 'ubuntu'
      env:
      secretEnv: ['_URL']
      script: |
          #!/usr/bin/env bash
          export URL="$$_URL/movies"
          #YOU HAVE TO PUT YOUR COMPUTATION HERE, IN MY CASE:
          echo $URL
    availableSecrets:
     secretManager:
      - versionName: projects/$PROJECT_ID/secrets/url/versions/latest
        env: '_URL'
    
    

  2. You have to print the env var URL in your script, like that

    - name: 'ubuntu'
      env:
       - 'URL="$$_URL/movies"'
      secretEnv: ['_URL']
      script: 'echo $$URL'
    availableSecrets:
     secretManager:
      - versionName: projects/$PROJECT_ID/secrets/url/versions/latest
        env: '_URL'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search