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

rsandell
Copy link
Member

@rsandell rsandell 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

… 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.
Copy link
Member

@abayer abayer left a 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
Copy link
Member

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>
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (item instanceof SCMSourceOwner) {
 ...
}

@rsandell
Copy link
Member Author

@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) {
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

@rsandell
Copy link
Member Author

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

@stephenc
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadocs on this class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

@stephenc
Copy link
Member

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
Copy link
Member

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
    

Copy link
Member

@stephenc stephenc left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants