Cyrus Devnomad
08/22/2024, 7:45 AM{
"uuid": "xxxxxxxxxxxxxxxxxxxxxxx",
"description": "Trigger Azure DevOps pipeline on pact change",
"enabled": true,
"request": {
"method": "POST",
"url": "<https://dev.azure.com/xxxxxxx/xxxxxxx/_apis/build/builds?api-version=6.0>",
"headers": {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"body": {
"definition": {
"id": 124
},
"sourceBranch": "refs/heads/xxxxxxxxxxxxxxxxxxx"
}
},
"events": [
{
"name": "contract_content_changed"
}
],
"updatedAt": "2024-08-22T07:35:01+00:00",
"createdAt": "2024-08-22T07:33:25+00:00"
}
Rather than with username/password properties configured like this:
{
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"description": "Trigger Azure DevOps pipeline on pact change",
"enabled": true,
"request": {
"method": "POST",
"url": "<https://dev.azure.com/xxxxxxxxxx/xxxxxxxxxxxx/_apis/build/builds?api-version=6.0>",
"headers": {
"Content-Type": "application/json"
},
"body": {
"definition": {
"id": 124
},
"sourceBranch": "refs/heads/xxxxxxxxxxxxxxxxxx"
},
"username": "xxxxxxxxxx",
"password": "**********"
},
"events": [
{
"name": "contract_content_changed"
}
],
"updatedAt": "2024-08-22T07:38:46+00:00",
"createdAt": "2024-08-21T17:09:42+00:00"
}
I'm asking this because I was successful with the former type of requests against Azure DevOps API but not with the latter type of requests.Matt (pactflow.io / pact-js / pact-go)
Cyrus Devnomad
08/23/2024, 3:10 PMdocker pull pactfoundation/pact-cli:latest
docker run pactfoundation/pact-cli:latest pact-broker create-or-update-webhook <https://dev.azure.com/xxxxxxxx/xxxxxxxx/_apis/build/builds?api-version=7.0> --description "Trigger Build-Service-CIRS.API pipeline whenever ConsumerX to ProviderX pact changes" --request POST --header "Content-Type: application/json Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" --data '{"definition": {"id": 124}, "sourceBranch": "${pactbroker.consumerVersionBranch}", "parameters": "{\"pact_url\": \"${pactbroker.pactUrl}\"}"}' --consumer="ConsumerX" --provider="ProviderX" --user=Username:$AzureToken --contract-content-changed --broker-base-url=$PactBrokerBaseUrl --broker-username=$PactBrokerUsername --broker-password=$PactBrokerPassword --uuid=xxxxxxxxxxxxx
The command above for example creates a webhook like this for example:
...
"headers": {
"Content-Type": "application/json Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
...
As opposed to a header like the following that I could successfully test against Azure DevOps API:
...
"headers": {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
...
But in the meantime this is no longer an issue for me, because I was successful to authenticate against Azure DevOps API with a webhook request looking like this:
{
"uuid": "xxxxxxxxxxxxxxxxxxxxxxx",
"description": "Trigger Providerx pipeline whenever ConusmerX to ProviderX pact changes",
"consumer": {
"name": "ConsumerX"
},
"provider": {
"name": "ProviderX"
},
"enabled": true,
"request": {
"method": "POST",
"url": "<https://dev.azure.com/xxxxxxx/xxxxxxx/_apis/build/builds?api-version=7.0>",
"headers": {
"Content-Type": "application/json"
},
"body": {
"definition": {
"id": 124
},
"sourceBranch": "${pactbroker.consumerVersionBranch}",
"parameters": "{\"pact_url\": \"${pactbroker.pactUrl}\"}"
},
"username": "Username",
"password": "**********"
},
"events": [
{
"name": "contract_content_changed"
}
],
"createdAt": "2024-08-22T17:29:29+00:00"
}