-
Notifications
You must be signed in to change notification settings - Fork 277
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
[JENKINS-71616] Use full project name instead of related name for comparing job names #490
base: master
Are you sure you want to change the base?
[JENKINS-71616] Use full project name instead of related name for comparing job names #490
Conversation
…omparing job names
// Use transformed fullDisplayNameFor to avoid | ||
// ambigous comparing between same name projects but located at different folders | ||
// FolderName » jobName to FolderName/jobName | ||
if (jobName.equals(item.task.getFullDisplayName().replace(" » ", "/"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that the displayName
can be anything and change almost at any time and doesn't need to be anything like jobName
that is gained from getName
/getFullName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is change the strict comparison between jobNames to regexp something like ".*jobName$"
But in this case we will have collision with projects located at the different projects folders with same names. This is quite less possible scenario, then I'm going to fix.
@rsandell what do you think is it ok to fix it this way?
@rsandell could you please have a look to the last change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the lesser evil for this issue.
Could you provide some tests for it as well please?
@@ -233,8 +234,16 @@ private void cancelMatchingJobs(GerritTriggeredEvent event, String jobName, Caus | |||
List<Queue.Item> itemsInQueue = Queue.getInstance().getItems((Queue.Task)getJob()); | |||
for (Queue.Item item : itemsInQueue) { | |||
if (checkCausedByGerrit(event, item.getCauses())) { | |||
if (jobName.equals(item.task.getName())) { | |||
// Use regexpt .*jobName to avoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Item task is always an instance of hudson.model.Item
I think, so you could check if this is the case and if yes cast to Item
and then use getFullName()
for the comparison. No need use a regex here.
@rsandell Found the same and I have a fix for this in my pull request too. According to what I understand the comparison can be done differently. |
https://issues.jenkins.io/browse/JENKINS-71616
If project has complicated name like folder/project-name then buildCurrentPatchesOnly feature does not work because of cancelMatchingJobs gets parametr jobName as full name but for comparing it uses just relative name without folder or parent project item.task.getName()).
Cannot get fullName form the task. Workaround is transform fullDisplayName with replacing separator from " » "to "/"
item.task.getFullDisplayName().replace(" » ", "/")
Don't have any idea how to prepare tests, looks like test implementation requires much more time then fix.
Testing done
Submitter checklist