I've tried many variations but without success.
I am trying to achieve this functionality but using a parameter of emai addresses and groups:
This works:
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
onTimeout: reject
notifyUsers: |
[muttsMitts]\release_group
admin@muttsMitts.com
instructions: 'Please validate the build configuration and resume'
With parameter Creating a string as a variable, looping, passing just the original object.
parameters:
- name: 'emailList'
type: object
default:
- '[muttsMitts]\release_group' # I have to put the quotes around the string
- [muttsMitts]\release_group
- job: manual_approval
displayName: "Manual Approval"
pool: server
timeoutInMinutes: 4320 # job times out in 3 days
variables:
- name: emailList
value: ${{join(', ', parameters.emailList)}}
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
onTimeout: reject
notifyUsers: |
${{each email in parameters.emailList}}
${{email}}
instructions: 'Please validate the build configuration and resume'
Returns error:
Encountered error(s) while parsing pipeline YAML:
/azure-pipelines.yml (Line: 96, Col: 24): The directive 'each' is not allowed in this context. Directives are not supported for expressions that are embedded within a string. Directives are only supported when the entire value is an expression.
You could always use a string and just pass through the parameter value.
In your reusable job, just define a string parameter:
# job.yaml
parameters:
- name: notifyUsers
type: string
default: ''
jobs:
- job: manual_approval
displayName: Manual Approval
pool: server
timeoutInMinutes: 4320 # job times out in 3 days
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
onTimeout: reject
notifyUsers: ${{ parameters.notifyUsers }}
instructions: Please validate the build configuration and resume
Then you can invoke it like that:
jobs:
- template: ./job.yaml
parameters:
notifyUsers: |
[muttsMitts]\release_group
admin@muttsMitts.com
If you'd like to use an array, your approach works. you just need to have a join on line break:
# job.yaml
parameters:
- name: notifyUsers
type: object
default: []
jobs:
- job: manual_approval
displayName: Manual Approval
pool: server
timeoutInMinutes: 4320 # job times out in 3 days
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
onTimeout: reject
notifyUsers: ${{ join('\n', parameters.notifyUsers) }}
instructions: Please validate the build configuration and resume
Then invoke it like that:
resources:
- repo: self
trigger: none
pr: none
jobs:
- template: ./job.yaml
parameters:
notifyUsers:
- '[muttsMitts]\release_group'
- 'admin@muttsMitts.com'