0

I have a dynamically created variable inside a CI Pipeline, let's call it "var: $(version.number).$(Date:yyyyMMdd)". I wish to reuse this as a part of the Publish Test Results task in a CD Pipeline so I can link both together and have a valid reference. But I can't fathom how to do this.

This is the yaml for the Publish Test Results task in it's most basic form.

steps:
- task: PublishTestResults@2
  displayName: 'Publish Test Results **/TEST-*.xml'

Any pointers will be gratefully accepted.

1 Answer 1

1

We could write it out to a json/xml file via power shell task, and publish the file as artifacts. Then read in that file via PowerShell in your release definition.

Build Definition

ConvertTo-Json | Out-File "file.json"

Release Definition

Get-Content "file.json" | ConvertFrom-Json

Also, we could pass the variable from build to release via the extension Variable Tools for Azure DevOps Services.

Steps:

Build Definition and result

enter image description here

Release Definition and result

enter image description here

In addition, I found a blog and save the variable to csv file, you could also refer to Passing variables in VSTS, from Build to Release and between environments.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Vito, this is a brilliant explanation!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.