jenkinsci / jms-messaging-plugin

https://plugins.jenkins.io/jms-messaging
12 stars 37 forks source link

A job is triggered when it shouldn't when using RabbitMQ #185

Closed itzikb closed 4 years ago

itzikb commented 4 years ago

I have two freestyle jobs: One that I configure with CI notifier and the other one which I have a build trigger. job1 definition job2 definition

The second job is triggered even though it shouldn't (If I understand correctly) because it expected the message to hold {"foo":"boo"} whether the first job sends {"foo":"boo1"}

scoheb commented 4 years ago

@Zlopez Can you please take a look at this one?

Zlopez commented 4 years ago

@itzikb Do you have the logs of job2, there should be the exact message you get on INFO log level.

itzikb commented 4 years ago

@Zlopez I'm having a different problem now when trying to reproduce. The IP of the RabbitMQ server changed. I Changed it in JMS Messaging Providers but In the log I see that the old IP is used (Even though the new one is saved).

itzikb commented 4 years ago

Restarting Jenkins - the IP changed (Is it a known bug)?

Which Log are you referring to?

Jenkins Log

Scheduling job 'test2' based on message:
{"foo":"boo1"}
Mar 30, 2020 5:59:11 PM WARNING hudson.security.csrf.CrumbFilter doFilter
Found invalid crumb 7c95c9e6a4bfbcfeeba39e02775963f7efdd40857f41a9773b694e831daca69c. If you are calling this URL with a script, please use the API Token instead. More information: https://jenkins.io/redirect/crumb-cannot-be-used-for-script
Mar 30, 2020 5:59:11 PM WARNING hudson.security.csrf.CrumbFilter doFilter
No valid crumb was included in request for /ajaxBuildQueue by admin. Returning 403.
Mar 30, 2020 5:59:11 PM WARNING hudson.security.csrf.CrumbFilter doFilter
Found invalid crumb 7c95c9e6a4bfbcfeeba39e02775963f7efdd40857f41a9773b694e831daca69c. If you are calling this URL with a script, please use the API Token instead. More information: https://jenkins.io/redirect/crumb-cannot-be-used-for-script
Mar 30, 2020 5:59:11 PM WARNING hudson.security.csrf.CrumbFilter doFilter
No valid crumb was included in request for /ajaxExecutors by admin. Returning 403.

Job2 console log

Triggered by CI message.
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/test2
[test2] $ /bin/sh -xe /tmp/jenkins8746323871627348214.sh
+ echo hello2!
hello2!
+ echo message is {"foo":"boo1"}
message is {"foo":"boo1"}
Finished: SUCCESS
Zlopez commented 4 years ago

@itzikb The first log is what I needed to verify the received message.

@scoheb For check verification I'm using the same approach as in ActiveMQ, so this looks more like issue in the ProviderData.verify method. Isn't there something similar to like instead of exact match?

Zlopez commented 4 years ago

@scoheb Looking at the code, this is the exact method that is called to verify the checks JMSMessagingProvider.verify

scoheb commented 4 years ago

The current default behaviour is that we use the following in the verify() method:

return Pattern.compile(expectedValue).matcher(actualValue).find();

which returns true for:

def expectedValue = "boo" def actualValue = "boo1"

If you want an exact match, then you need to use a regexp

expectedValue = "^boo$"