There is a job template (externally managed). I want to use this template in my pipeline. I have to provide a number of parameters for this template to work. I would like to dynamically generate the value for one of these parameters, namely a password.
I thought of using pwgen for this like so:
jobs:
- job: generate_key_password
steps:
- bash: |
set -e
echo "Installing pwgen"
sudo apt install pwgen && echo "Successfully installed pwgen"
pw=$(pwgen -y -s 25 1)
displayName: Installing pwgen
I then would like to use the output of this step in a template:
- template: /x/y/z/a-template.yml@some-repo
parameters:
theParameterName: <this should be the password I generated>
I have used vso in the past to pass on variables from one job to another, but this doesn't seem to be possible in the context of my task (I cannot set dependsOn). Is there any straightforward strategy to pass on the variable and use it in a subsequent template job or not?
Tied together, it would look like this:
stages:
- stage: the_stage
jobs:
- job: generate_key_password
steps:
- bash: |
set -e
echo "Installing pwgen"
sudo apt install pwgen && echo "Successfully installed pwgen"
pw=$(pwgen -y -s 25 1)
displayName: Installing pwgen
- template: /x/y/z/a-template.yml@some-repo
parameters:
theParameterName: <this should be the password I generated>

pwcan not be render in parameters.theParameterNamewould throw an error to notice to provide the value, because it render at the beginning and thepware not produced out.pwgenerated job in stage1 anda-template.ymljob in stage2, so that you can setdependsOnon the stage to avoid on the job template.dependsOnparameter and others that might make your life (and others') easier.