VSTS build variable publish as artifact

Powershell is a powerful tool. It's easy to create file in the fly, read from file, call some API. It's easy and flexible. I decided that I want to use all those tree operations in one of my VSTS pipelines.
The scenario is:
- take variable filled while build queuing
- write it's value to text file that will be available as artifact
- use artifact file value (read the file)
- set Release variable with file content
- use release variable for API call (or any other use).

1. Build that takes variable in queuing time and writes it to text file that is published as artifact.
I'm adding powershell inline task that takes in user input text and path where the file should be temporary stored. The path for file is used in publish task as root directory for files to publish. The most important part of the script is getting the parameters and creating new file:
Param(
  [string]$userNotes,  
  [string]$path 

New-Item $path\UserNotes.txt -type file -force -value "$userNotes"

with attributes:
-userNotes $(someVariable) -path "$(Build.SourcesDirectory)"



Now I have user notes in artifacts I can read it in VSTS Release.

Komentarze

Popularne posty