Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook triggered without contract change #270

Closed
s1apped opened this issue Apr 25, 2019 · 13 comments
Closed

Webhook triggered without contract change #270

s1apped opened this issue Apr 25, 2019 · 13 comments

Comments

@s1apped
Copy link

s1apped commented Apr 25, 2019

Hi,

I have issue with Pact Broker Webhook. It should trigger only when Pact change but it triggers for any change in consumer (new commit which is also the Tag)

{
"consumer": {
"name": "a.service"
},
"provider": {
"name": "b.service"
},
"request": {
"method": "POST",
"url": "https://jenkins.test.eu/job/b_build/build",
"headers": {
"Accept": "application/json"
},
"username": "test",
"password": "test"
},
"events": [
{
"name": "contract_content_changed"
}
]
}

I also have can-i-deploy in pipeline:
"/pact-broker can-i-deploy --retry-while-unknown=12 --retry-interval=10 --pacticipant a.service --version ${GIT_COMMIT} --broker-base-url http://10.10.10.10"

I checked differences but nothing:
No previous distinct version was found for Pact between

Thank you.

@bethesque
Copy link
Member

new commit which is also the Tag

Are you tagging the version with the commit sha as well? That's the reason the webhook is firing. The logic for determining whether or not to trigger the webhook is: if the pact's consumer version is untagged, check the previous untagged pact, and fire if the content is different, or there was no previous version. If the pact's consumer version is tagged, then it looks for the latest version with each of the tags, and fires if the content has changed or if there was no previous version with that tag.

@s1apped
Copy link
Author

s1apped commented Apr 27, 2019

No. Consumer is tagged with branch name. SHA is a version of both consumer and provider.

Pact's consumer version is tagged, then it looks for the latest version with each of the tags, and fires if the content has changed or if there was no previous version with that tag.

  1. Pact's consumer version is tagged = TRUE
  2. Find latest version with tag = TRUE
  3. Contract has changed = FALSE
  4. No previous version with tag = FALSE

Based on above if I understand correctly webhook shouldn't be triggered?

@bethesque
Copy link
Member

bethesque commented Apr 29, 2019

Hm. This is confusing then. The other day I did a massive refactor of all the logic and added in some detailed logging for showing why the webhook gets triggered. Let me do a release do you can use that. Are you using the docker image?

@s1apped
Copy link
Author

s1apped commented Apr 30, 2019

Yes I'm using docker image.

@bethesque
Copy link
Member

Grab dius/pact-broker:2.31.0-1 or try the newer smaller pactfoundation/pact-broker:edge. You'll need to turn the log level up to debug. This is the class that will do the logging - it will be one of the reasons in here: https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/webhooks/trigger_service.rb

@s1apped
Copy link
Author

s1apped commented May 1, 2019

I got below message
trigger

Pact is tagged:
pact_broker

matrix (not sure if results are displayed properly, looks like it verified previous consumer versions?)
matrix

Consumer can-i-deploy returns
can-i-deploy

Since previous pact was tagged not sure why commit that doesn't change contract triggers provider build.

@s1apped
Copy link
Author

s1apped commented May 2, 2019

@bethesque I setup everything again and did some more digging

  1. I created initlial Pact
    notRun
  2. pb:all-pact-versions returned 1 pact
  3. pb:latest-untagged-pact-version returned 404 Not Found
  4. pb:latest-tagged-pact-version returned JSON
    curl -X GET http://0.0.0.0/pacts/provider/customer/consumer/invoice/latest/add-pact-cdc-tests
  5. push consumer commit that doesn't change contract
  6. run consumer Jenkins job
  7. Provider got triggered even though nothing has changed
  8. pb:all-pact-versions returned 2 pacts
  9. pb:latest-untagged-pact-version returned 404 Not Found
  10. pb:latest-tagged-pact-version returned JSON

The only differences between pact versions are "createdAt": or "_links":
Not sure why "first time untagged pact published" is the cause.

@s1apped
Copy link
Author

s1apped commented May 14, 2019

@bethesque did you have a chance to look into? Any information would be greatly appreciated.

@bethesque
Copy link
Member

I'm so sorry, I've been crazy busy. I'll try and get on to this.

@bethesque
Copy link
Member

Which lib are you using to publish the pacts @s1apped? I'm wondering if perhaps the tagging is happening after the pact publication. It should come first.

@s1apped
Copy link
Author

s1apped commented Jun 11, 2019

Hi @bethesque I'm using junit.

@bethesque
Copy link
Member

Fix has been released to pact-jvm. Please try again with the latest version. pact-foundation/pact-jvm#892 (comment)

@s1apped
Copy link
Author

s1apped commented Jun 25, 2019

@bethesque it looks good now! Thank you

@s1apped s1apped closed this as completed Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants