Answers: <p>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 <code>root['workItems'][0]</code>, 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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-06-24T13:52:41.493Z
Answers: 2021-06-24T13:52:41.493Z
Answers: Jeremy Meadows
Body: <p>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 <code>SELECT [System.Id] FROM WorkItems WHERE [System.WorkItemType] = 'Release' AND [Com.Pipeline] = &quot;$(Release.DefinitionName)&quot;</code> (or equivalent)?</p>
  <p>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?</p>
  
Tags: <azure-devops>
Title: ADO: Able to use pipeline variables in a query?
UserDisplayName: Jeremy Meadows
ThreadText: # ADO: Able to use pipeline variables in a query?
  
  (Asked by: username_0 on 2021-06-21)
  
  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?
  
  **Tags:** azure-devops
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-06-24. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  