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-48035] Add a GitHubRepositoryNameContributor that recognises… #170
Conversation
… multi branch The existing name contributors could only find the repo name if a build of a branch had been made and added git build data to the job. Since branches are discovered and built after GitHubSCMSource.afterSaved is called there was no repo names recognised to add webhooks to. This only solves the case when a single multi branch project is created. Because when an org folder creates the multi branch jobs it does not call afterSaved on the children. So that needs to be fixed someplace else.
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.
Any way you can add a test for the new class?
|
||
import java.util.Collection; | ||
|
||
@Extension |
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.
Javadoc please
pom.xml
Outdated
@@ -68,6 +68,11 @@ | |||
<artifactId>display-url-api</artifactId> | |||
<version>0.2</version> | |||
</dependency> | |||
<dependency> |
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.
Oh I am not happy about this being escalated from test. Ping me tomorrow. We need to find a different way
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.
I first tried with SCMSource.SourceByItem.findSource(item)
but the problem there was that it only found the source for actual branch jobs, so it doesn't work on afterSave
because there are no branch jobs available at that time, so still no repository to discover.
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.
if (item instanceof SCMSourceOwner) {
...
}
@abayer well, I can't add a test that verifies the actual issue because of rate limits on GitHub etc. I'm trying to come up with something. |
|
||
@Override | ||
public void parseAssociatedNames(Item item, Collection<GitHubRepositoryName> result) { | ||
if (item instanceof MultiBranchProject) { |
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.
instanceof SCMSourceOwner
and you are only using that classes method anyway
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.
🤦♂️
@stephenc any thoughts on where to put in a call to |
Well that should be in branch-api |
|
||
import java.util.Collection; | ||
|
||
@Extension |
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.
Javadocs on this class
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.
🤦♂️
Should be addressed by jenkinsci/branch-api-plugin#120 |
@Extension | ||
public class GitHubSCMSourceRepositoryNameContributor extends GitHubRepositoryNameContributor { | ||
|
||
@Override |
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.
🐜 (From https://github.com/jenkinsci/scm-api-plugin/blob/master/CONTRIBUTING.md#javadoc):
- When a method is overriding a method from a super-class / interface, unless the semantics of the method have changed it is sufficient to document the intent of implementing the super-method's contract with:
/** * {@inheritDoc} */ @Override
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.
Though my inner pedantic perfectionist has issues with ruining the every method gets javadoc rule
… multi branch
The existing name contributors could only find the repo name if a build
of a branch had been made and added git build data to the job.
Since branches are discovered and built after GitHubSCMSource.afterSaved is called
there was no repo names recognised to add webhooks to.
This only solves the case when a single multi branch project is created.
Because when an org folder creates the multi branch jobs it does not call
afterSaved on the children. So that needs to be fixed someplace else.
@reviewbybees