Test the emails your app sends (sign-up confirmations, password resets, one-time codes) inside your pipeline.
Create an environment API key at https://app.mailpier.io and store it as a secret pipeline variable, e.g. MailPierInboxKey.
Make your app send a mail to an address of your environment: anything@<environment>.<account>.mailpier.io (or anything@<account>.mailpier.io).
Add the task:
- task: MailPierInboxWait@1
name: mail
inputs:
apiKey: '$(MailPierInboxKey)'
address: 'signup-$(Build.BuildId)@qa.acme.mailpier.io'
subjectContains: 'Confirm'
timeoutSeconds: '120'
- script: dotnet test --filter ConfirmSignup # reads MPI_CODE / MPI_LINK
env:
MPI_CODE: $(MailPierInbox.Code) # secret variables: map them into env explicitly
MPI_LINK: $(MailPierInbox.Link)
The step fails when no mail arrives in time. The code and the link are secret variables (they are credentials): they are masked
in the log, never printed by the task, and like every secret variable reach a script only when mapped into env: as above. Later steps of the job read $(MailPierInbox.Code), $(MailPierInbox.Link) and
$(MailPierInbox.MessageId); other jobs read the output variables dependencies.<job>.outputs['mail.Code'] (and Link, MessageId).