I've included an azure-pipeline.yml file that references templates for auditing, testing, building, and deployment.
What I need to work on is piping Azure DevOps Library values/secrets. The catch is that each search refers to different strings/secrets.
E.g. The node.js services have this service A has a cache connection string as process.env.CACHE_CONNECT service B has a cache connection string as process.env.CACHE_CONNECTION_STRING service C has a cache connection string as process.env.CONNECT_TO_CACHE
I intend to pass in a parameter list and then map over it to create variables that can be used in multiple places and also passed into the docker build/deploy steps.
The issue is creating variable key/value pairs dynamically.
Is this a possibility? Is there a better way to approach this?
name: CD
parameters:
- name: environment
type: object
default:
- foo
- bar
- name: dotEnvPairs
type: object
default:
- envKey: 'NODE_ENV'
libraryKey: Production
- envKey: 'CACHE_STRING'
libraryKey: 'testMe'
variables:
- group: WebDevelopment
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- ${{ each value in parameters.dotEnvPairs }}:
# The goal is to do something like this:
# <value.envKey> = <variableGroup<value.libraryKey>
- script: |
echo Env name is ${{ value.envKey }}
echo Env value is ${{ value.libraryKey }}
echo Static key $(testMe)
echo Dynamic A key %$(value.libraryKey)%
echo Dynamic B key %${{value.libraryKey}}%
echo Dynamic C key %$(variables[value.libraryKey]: value)%
I'm automating service deployment, but I can't touch any of the base code at this time.