azure-devops-cli-extension
azure-devops-cli-extension copied to clipboard
[Feature Request] az pipeline run --resources (for multi repo checkout)
Is your feature request related to a problem? Please describe. With Web GUI for the pipelines run, I can select branch/commit on each additional repo being checked out under resources section but I don't see a way to do that from the cli.
Describe the solution you'd like I want to be able to choose branch/commit on each additional repo to check out.
Do we have any ETA on this feature request? It will be really helpful to get this feature working so we can send information about multiple repos in the request. We have Linux build pipeline in azure devops project which needs multiple repos from multiple projects. We use az pipeline run but are not able to send multiple repository information because of the current limitation.
Agree it'd be very useful to be able to specify resources during scheduling a new run from Azure CLI.
As a workaround, one can query this Azure DevOps API via curl, as suggested here as specify the desired pipeline resource.
HOST='https://hostname.com:8443/tfs'
DEVOPS_ORG='MyOrg'
DEVOPS_PROJECT='MyProject'
DEVOPS_PAT=asdasd1236secretazuredevopstoken
PIPELINE_ID=123456
curl \
-X POST \
"${HOST}/${DEVOPS_ORG}/${DEVOPS_PROJECT}/_apis/pipelines/${PIPELINE_ID}/runs?api-version=6.0-preview.1" \
-H "Content-Type: application/json" \
-u "${DEVOPS_PAT}": \
-d @<(cat <<EOF
{
"stagesToSkip": [],
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/pipeline-yaml-definition-branch-name"
}
},
"pipelines": {
"ResourcePipeline1": {
"version": "8.54"
},
"ResourcePipeline2": {
"version": "3.14"
}
}
},
"templateParameters": {
"parameter1": "value1",
"parameter2": "value2",
},
"variables": {
"system.debug": {
"value": "true"
}
}
}
EOF
)
This can also be done with az devops invoke
az devops invoke \
--area pipelines \
--organization https://dev.azure.com/<ORG_NAME> \
--route-parameters project=<PROJECT_NAME> pipelineId=<PIPELINE_ID> \
--resource runs \
--api-version=7.2-preview \
--http-method=post \
--in-file=req.json
req.json
{
"stagesToSkip": [],
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/<BRANCH_NAME>"
}
}
}
}
You can find documentation for the request JSON payload here: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-7.2