I need to know the person who created a pipeline in ADO
https://dev.azure.com/mycompany/myproject/_apis/pipelines/***?api-version=7.1
I get everything but a "createdby" field
{
"_links": {
"self": {
"href": "https://dev.azure.com/****/****/_apis/pipelines/****?revision=**"
},
"web": {
"href": "https://dev.azure.com/****/****/_build/definition?definitionId=****"
}
},
"configuration": {
"path": "azure-pipelines.yml",
"repository": {
"id": "*******************",
"type": "***************"
},
"type": "yaml"
},
"url": "https://dev.azure.com/****/****/_apis/pipelines/****?revision=**",
"id": ***,
"revision": **,
"name": "****",
"folder": "\\****"
}
how can I achieve this ?
thanks for your help
Based on your description, you need to get the user who creates the Pipeline.
To meet your requirement, you can use the Rest API: Definitions - Get Definition Revisions
GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}/revisions?api-version=7.1
In the Response, you can check the response with revision value 1, where the changed user(changedBy
) corresponds to the user who creates the pipeline.
For example:
"value": [
{
"revision": 1,
"name": "txx",
"changedDate": "2024-10-15T14:41:59.987Z",
"changeType": "add",
"definitionUrl": "xx",
"changedBy": {
"displayName": "xxx",
"url": "xx",
.....
"id": "dd61a310-16c1-6ca5-a217-f243df542c22",
"uniqueName": "xx",
"imageUrl": "xx",
"descriptor": "msa.ZGQ2MWEzMTAtMTZjMS03Y2E1LWEyMTctZjI0M2RmNTQyYzIy"
}
},
]
PowerShell sample:
$token = "PAT"
$BuildDefinitionID = PipelineID
$OrgName= "OrganizationName"
$ProjName= "ProjectName"
$GetBuilddefinitionurl="https://dev.azure.com/$($OrgName)/$($ProjName)/_apis/build/definitions/$($BuildDefinitionID)/revisions?api-version=7.1"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$GetBuildRevisions= Invoke-RestMethod -Uri $GetBuilddefinitionurl -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
foreach($revision in $GetBuildRevisions.value)
{
if($revision.revision -eq "1")
{
$PipelineCreatorID = $revision.changedBy.id
$PipelineCreatorName= $revision.changedBy.uniqueName
echo "Creator ID: $PipelineCreatorID ; Creator Name: $PipelineCreatorName"
}
}