HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

ADO: Able to use pipeline variables in a query?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
queryadovariablesusepipelineable

Problem

I would like to have a gate which requires at least one work item of the 'Release' type associated with the pipeline. Is there a way to have the gate query execute SELECT [System.Id] FROM WorkItems WHERE [System.WorkItemType] = 'Release' AND [Com.Pipeline] = "$(Release.DefinitionName)" (or equivalent)?

I need it to work through multiple pipelines, which is why I would like to use on of the built-in variables to avoid creating a hundred separate queries. If not possible, is there a better way to stop deployment from moving to the next stage if there isn't a specific associated work item?

Solution

So ended up reading about the WIQL API calls, and used an 'Invoke Web Request' task to execute the above query, with the success criteria being root['workItems'][0], which errors out if there isn't an element present. Not quite as elegant as the Query task I was shooting for, but it serves its purpose.

Context

StackExchange DevOps Q#14205, answer score: 1

Revisions (0)

No revisions yet.