PowerShellVSTS

Create VSTS Build Definitions using PowerShell

For my current project assignment I was asked to share a PowerShell script which creates VSTS build + phase dynamically. To make this blog short let me show a simple build definitions sample.

With no wait here is the code

Step 1: You need Personal Access Token (PAT). Go get it.

Step 2: Convert to base64 string.

Step 3: Define your build (In my case its a JSON file)

Step 4: Consume the end point as per the documentation.

Before – Empty Builds and Pipeline

After the successful execution of the script! Out new build is created with one phase but no expected working phase (This is for demo)

Here is the sample JSON.

Just export the existing build as JSON to get more insights!

Leave a Reply

Your email address will not be published. Required fields are marked *