Open prasad-sunkara opened 4 years ago
pipelines
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.
Hello. Is there an update on this functionality?
devops service team should take a look
@yonzhan What is happening here? It is quite important for us to be able to select the stages to be run in our pipelines.
@adamnybergelli I mean az pipelines CLI commands are owned by devops service team. They should look into this issue.
@yonzhan thanks, and how to I reach that team?
There is msftbot commented above to route to the appropriate team.
any update on this? @narula0781, @ashishonce, @romil07
The following is a workaround to deploy a single stage, using the Azure Devops CLI and the Azure Devops REST API NOTE: This has only been tested using the new YAML pipelines.
az pipelines list --query "[].{ID: id, Name:name}" --output tsv
az pipelines build list --definition-ids <Pipeline ID> --query "[].{Name:definition.name,Uri:uri}" --output tsv
The build list from the previous command will have a Uri column with the following signature:
vstfs:///Build/Build/
NB: Used this tutorial to get the resources needed to call the API through Powershell (Thank you, Olivier Miossec! @omiossec): https://dev.to/omiossec/getting-started-with-azure-devops-api-with-powershell-59nn
NB: I used the Developer Tools in Chrome to view the request when clicking the "ReRun" button on a build. The URL in the Network tab for the call gave me the ProjectGuid and BuildStage:
Full Script:
$BuildId = <Build ID>
$AzureDevOpsPAT = "<Personal access token from tutorial above>"
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)"))}
$OrganizationName = "<Organization Name>"
$ProjectGuid = "<Project Guid. You may be able to use the ProjectName as well>"
$BuildStage = "<Build Stage>"
$requestBody = @{
state="retry"
}
$requestBodyJson = $requestBody | ConvertTo-Json
$uri = "https://dev.azure.com/$($OrganizationName)/$($ProjectGuid)/_apis/build/builds/$($BuildId)/stages/$($BuildStage)?api-version=6.0-preview.1"
Try
{
Invoke-RestMethod -Uri $uri -Method patch -body $requestBodyJson -Headers $AzureDevOpsAuthenicationHeader -ContentType 'application/json'
} Catch {
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
}
Once you issue the command, you should be able to see the stage triggered in Azure Devops.
Despite of having a "hacky" workaround thanks to @aucinc123, I think this feature should be included in az pipelines release.
Bump for it being VERY useful to be able to simply do the following in the CLI (or a Powershell equivalent):
az pipelines release deploy --definition-name
For those of us whose corporate policy disallows CD, with all deployments having to go through gates, etc, our releases are all "Manual Only" rather than "On Build". I have CLI scripts that run pipelines, that create releases... but I still have to go back to the DevOps website to actually deploy the stage in question, after the release is created.
...wanted to add a few comments onto last few posts...
Def agree the ability to use cli to run specific stages would be VERY helpful... esp with 'multi-stage' .yaml pipelines that have dependencies (or not for that matter). Additionally, it would be nice to be able to select to run ANY particular stage - not JUST a deployment stage, AND ALSO - take into account CD approvals/checks (associated with environments) - some way to approve from command line IF you have permissions...
Is this still being investigated? I see a huge need for this.
Agreed still a huge need for this. Any updates?
Bump for it being VERY useful to be able to simply do the following in the CLI (or a Powershell equivalent):
az pipelines release deploy --definition-name --stage --release
For those of us whose corporate policy disallows CD, with all deployments having to go through gates, etc, our releases are all "Manual Only" rather than "On Build". I have CLI scripts that run pipelines, that create releases... but I still have to go back to the DevOps website to actually deploy the stage in question, after the release is created.
And most of the time these exact corporates get attracted to Microsoft software like flies to shit. And you go through the rabbit hole of Microsoft to finally end up here knowing it is not possible. These corporates also hire excellent employees that create 20 "microservices" that needs to be deployed with manual approval process. Let me get back to happy clicking in the evening to cover up for the time I "wasted" trying to automate this. Microsoft just rocks Note1: My gratitude to the person who created this issue report and ending my chase to find the command in the Microsoft "documentation". Thanks for making me not waste more time trying to find the missing documentation. Note2: I already wasted a lot of time before this trying to make the azure devops python sdk to work for this. That is a total waste of time with no documentation at all. Microsoft is just marvelous
yes, please
still waiting)
I found a workaround which is not painfull.
In your pipeline add paratmeter
parameters:
- name: Build1
displayName: Build1?
type: boolean
default: true
And for stage add condition
stages:
- stage: 'Build1'
displayName: 'Build1' #Name displayed when viewing in Azure DevOps
condition: ${{ parameters.Build1 }}
dependsOn:
CLI supports parameters for pipeline execution. So you can pass this and it works in similar way as with stages selected "normal way".
Is there any update? I am waiting ......
I am looking for az cli pipeline+stage specific triggering as well, specifically being able to execute the cli commands from another pipeline, leveraging the calling account ADO permissions so that we can avoid PAT token generation and management.
If you don't want to increase number of parameters you can use variables defined on pipeline level configuration (Edit pipeline -> Variables)
Then you can set defaults for these each stage variables, like:
When you add new variable enable overwriting it:
In pipeline YAML file condition in stage will look like:
### Dev environment ###
- stage: dev_deployment
displayName: Dev Deployment
condition: eq(variables['stage_dev'], 'true')
...
### QA environment ###
- stage: qa_deployment
displayName: QA Deployment
condition: eq(variables['stage_qa'], 'true')
...
Running Dev stage only (Default stage_dev and stage_qa variables):
az pipelines run --organization $ORG --project $PROJECT_NAME --name $PIPELINE_NAME --branch $BRANCH --parameters deploy=true version=1.2.3
Running Dev and QA stages:
az pipelines run --organization $ORG --project $PROJECT_NAME --name $PIPELINE_NAME --branch $BRANCH --parameters deploy=true version=1.2.3 --variables stage_dev=true stage_qa=true
This has just come up as a requirement for us, we will look at some of the workarounds posted, but the general feature seems like a good, obvious candidate for inclusion in the az
CLI command.
[Enter feedback here] It seems az pipelines run doesn't work with any of the Release Pipelines. We use specific stages in our Release Pipeline to run automated tests and deploy code to various test environments. This functionality is needed to invoke specific stages from CLI.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.