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

[JENKINS-48035] Add a GitHubRepositoryNameContributor that recognises… #170

Merged
merged 6 commits into from Dec 18, 2017

Conversation

Projects
None yet
3 participants
@rsandell
Copy link
Member

commented Dec 11, 2017

… 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

[JENKINS-48035] Add a GitHubRepositoryNameContributor that recognises…
… 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.

@rsandell rsandell requested review from stephenc, abayer and svanoort Dec 11, 2017

@abayer
Copy link
Member

left a comment

Any way you can add a test for the new class?


import java.util.Collection;

@Extension

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 11, 2017

Member

Javadoc please

pom.xml Outdated
@@ -68,6 +68,11 @@
<artifactId>display-url-api</artifactId>
<version>0.2</version>
</dependency>
<dependency>

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 11, 2017

Member

Oh I am not happy about this being escalated from test. Ping me tomorrow. We need to find a different way

This comment has been minimized.

Copy link
@rsandell

rsandell Dec 12, 2017

Author Member

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.

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 12, 2017

Member
if (item instanceof SCMSourceOwner) {
 ...
}
@rsandell

This comment has been minimized.

Copy link
Member Author

commented Dec 12, 2017

@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) {

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 12, 2017

Member

instanceof SCMSourceOwner and you are only using that classes method anyway

This comment has been minimized.

Copy link
@rsandell

rsandell Dec 12, 2017

Author Member

🤦‍♂

@rsandell

This comment has been minimized.

Copy link
Member Author

commented Dec 12, 2017

@stephenc any thoughts on where to put in a call to afterSave when an OrgFolder creates the job?

@stephenc

This comment has been minimized.

Copy link
Member

commented Dec 12, 2017

any thoughts on where to put in a call to afterSave when an OrgFolder creates the job?

Well that should be in branch-api


import java.util.Collection;

@Extension

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 12, 2017

Member

Javadocs on this class

This comment has been minimized.

Copy link
@rsandell

rsandell Dec 12, 2017

Author Member

🤦‍♂

@stephenc

This comment has been minimized.

Copy link
Member

commented Dec 13, 2017

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.

Should be addressed by jenkinsci/branch-api-plugin#120

@Extension
public class GitHubSCMSourceRepositoryNameContributor extends GitHubRepositoryNameContributor {

@Override

This comment has been minimized.

Copy link
@stephenc

stephenc Dec 13, 2017

Member

🐜 (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
    
@stephenc
Copy link
Member

left a comment

Though my inner pedantic perfectionist has issues with ruining the every method gets javadoc rule

@stephenc stephenc merged commit 3bf8714 into jenkinsci:master Dec 18, 2017

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.