In my pipeline (bash, ubuntu-latest) i want to add into already created library a variable (last git commit hash) is it possible ??
Documentation not telling too much about it
CodePudding user response:
You could use this API to update the variable group:
Bash script:
curl --location --request PUT 'https://dev.azure.com/{OrgName}/{ProjName}t/_apis/distributedtask/variablegroups/{variablegroupsID}?api-version=7.0' \
--header 'Authorization: Basic {Base64PAT}=' \
--header 'Content-Type: application/json' \
--data-raw '{
"variables": {
"test": {
"value": "$(Build.SourceVersion)"
}
},
"id": 5,
"type": "Vsts",
"name": "1013",
"description": "",
"createdBy": {
"displayName": "{displayName}",
"id": "{id}",
"uniqueName": "{uniqueName}"
},
"createdOn": "2022-10-13T07:41:40.3066667Z",
"modifiedBy": {
"displayName": "{displayName}",
"id": "{id}",
"uniqueName": "{uniqueName}"
},
"modifiedOn": "2022-10-13T07:41:40.3066667Z",
"isShared": false,
"variableGroupProjectReferences": [
{
"projectReference": {
"id": "{Proj id}",
"name": "{Proj Name}"
},
"name": "1013",
"description": ""
}
]
}'
Variable group sample:
Running the script via Azure Pipeline (bash, ubuntu-latest)
Result:
Update1