DEV Community

Cover image for BulkRun Powershell Script for Azure Pipelines
Antonio Di Motta
Antonio Di Motta

Posted on

6 3

BulkRun Powershell Script for Azure Pipelines

Azure Devops provides a great UI for managing and run the pipelines, but sometimes we need to run it manually, just to reuse the deployment logic or when its required to run many of them.

To accomplish this job, I created a simple powershell script to run a set of pipeline programmatically by using the Azure Devops rest API and it requires a Personal Access Token

Example

# Step 1: Create the pipeline on Azure Devops with following yaml code. Below an example with parameters.

parameters:
  - name: name
    displayName: "Name"
    type: string
  - name: surname
    displayName: "Surname"
    type: string

pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello ${{ parameters.name }} ${{ parameters.surname }}
  displayName: 'Run a one-line script'
Enter fullscreen mode Exit fullscreen mode
# Step 2: Create a pipeline definition file (pipetorun.csv) with the information to run an ado pipeline for each row.
# The definitionid is the definitionid of Azure Devops pipeline
# Branch is the pipeline's branch.
# Parameters are defined as a dictionary (key=value separate by semicolon, key is equal the pipeline parameter name)

definitionid,name,branch,parameters
12,hello,main,name=Alan;surname=Turing
12,hello,main,name=Clude;surname=Shannon
12,hello,main,name=Tim;surname=Berners-Lee
12,hello,main,name=Edsger;surname=Dijkstra
12,hello,main,name=Leslie;surname=Lamport

# Step 3: Run five pipeline by using the script and the defintion file. (How to create a PAT )

.\BulkRun.ps1 -PAT personal-access-token -File .\pipetorun.csv
Enter fullscreen mode Exit fullscreen mode
# Result

hello inProgress on main -> https://dev.azure.com/dimotta/demo/_build/results?buildId=119
hello inProgress on main -> https://dev.azure.com/dimotta/demo/_build/results?buildId=120
hello inProgress on main -> https://dev.azure.com/dimotta/demo/_build/results?buildId=121
hello inProgress on main -> https://dev.azure.com/dimotta/demo/_build/results?buildId=122
hello inProgress on main -> https://dev.azure.com/dimotta/demo/_build/results?buildId=123
Enter fullscreen mode Exit fullscreen mode

Image description

The BulkRun script code is available here

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong · web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video 🌶️🔥

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay