1

we use floating licenses for our more expensive compilers/tools, so that we can do local development as well as our production builds. The license manager (flexLM) has an api we can query, so we could block the license. However, I cannot find a mechanism by which I can cause my pipeline to queue based on the state of an auxiliary variable or return value of a script or something like that.

This means that I can launch the build on any machine on which the compiler is installed but it will then fail if the license is not available and I will have to relaunch the pipeline. If I did that automatically I would effectively just block that machine until the license becomes available.

Is there anything I have missed that could achieve a "queueing until license becomes available" kind of thing?

Thank you, Manuel

Manuel S
  • 43
  • 4

1 Answers1

2

We can add the first task power shell in the pipeline definition and define new variable in the variable tab such as Value:true, then add script to check the license status, if the license is available, set the variable Value to true, if the license is not available, set the variable Value to False. Then add condition eq(variables['{variable name}'], '{variable value}') in the Second task.

After configure, if your license is available, the pipeline will run successfully.

Or we could check the license first, then call the below script to queue build pipeline.

$token = "$(pat)"
$url = "https://dev.azure.com/{Org name}/{project name}/_apis/build/builds?api-version=6.1-preview.6"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))


$JSON = @"
{
  "definition": {
    "id": {Build definition ID}
  }
}
"@

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON
write-host $response
Vito Liu
  • 7,525
  • 1
  • 8
  • 17
  • I like the approach! But I cannot see how it would go forward if the license was not available. If the license is not available the build just doesn't get queued? Ok, but that means we have to manually keep triggering this process until a license becomes available, no? – Manuel S Nov 16 '20 at 14:43
  • If you are using condition, the build will run and fail, you could refer to this [doc](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml) for more detail. If you are using the script, the script shared just queue the build, you need to add a judgment statement to check the license status, such as If(){ enter the script }. – Vito Liu Nov 17 '20 at 05:27
  • Hi Just checking in to see whether this issue is still blocking you now? Any update for this issue? – Vito Liu Nov 27 '20 at 09:39
  • Hi! The issue remains I believe. The solution you suggests makes the pipeline success rate look horrible without the build being broken. It's similar to a single machine with the azure cli being triggered to check licenses and launch the respective builds. But it seems that this should the azure main service triggering builds rather than having pipelines calling pipelines..?! – Manuel S Feb 01 '21 at 13:20