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-31319] Retrieve method was implemented using GH API #4

Merged
merged 3 commits into from
Nov 2, 2015

Conversation

recena
Copy link
Contributor

@recena recena commented Oct 28, 2015

JENKINS-31319

Console output example

Started by user anonymous
Connecting to GitHub Pull Requests using recena/****** (ec28dda8d2f4d4f59b8856ef56ed83d3e5106356)
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/seville-jam/website.git # timeout=10
Fetching upstream changes from https://github.com/seville-jam/website.git
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.helper store --file=/tmp/git3051648955860258488.credentials # timeout=10
 > git fetch --tags --progress https://github.com/seville-jam/website.git +refs/pull/*/merge:refs/remotes/origin/pr/*
 > git config --local --remove-section credential # timeout=10
Checking out Revision 5c1b15276ab71c027000e1653466945a160d66f5 (PR-4)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 5c1b15276ab71c027000e1653466945a160d66f5
 > git rev-list 5c1b15276ab71c027000e1653466945a160d66f5 # timeout=10
[Workflow] Allocate node : Start
Running on master in /home/recena/projects/cloudbees-github-pull-requests-plugin/work/jobs/CJP-3204-4/branches/PR-4/workspace
[Workflow] node {
[Workflow] echo
Hello World 10
[Workflow] } //node
[Workflow] Allocate node : End
[Workflow] End of Workflow

GitHub has been notified of this commit’s build result

Finished: SUCCESS

@reviewbybees specially, @jglick

@recena recena changed the title [CJP-3205] Retreive method was implemented using GH API [CJP-3205] Retrieve method was implemented using GH API Oct 28, 2015
@KostyaSha
Copy link
Member

CJP-3205

Can't login

@recena recena changed the title [CJP-3205] Retrieve method was implemented using GH API [WiP] Retrieve method was implemented using GH API Oct 28, 2015
@recena
Copy link
Contributor Author

recena commented Oct 28, 2015

@KostyaSha I'm sorry, my mistake. I'm going to file a JIRA ticket.

import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GHUser;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.*;
Copy link
Member

Choose a reason for hiding this comment

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

Please read @stephenc contributing guideline + checkstyle rules, they both against *. Every time you adding/removing classes imports will be collapsed to * or expanded to single that provides big useless changes in diff. i.e. here it is not obvious what was added.
PS in general there is no difference in performance because this imports influence only on build time AFAIK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KostyaSha This plugin does not have that guideline. Anyway, I've changed it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but after picking this rule i minimized my diffs :) it JFYI, you can ignore of course

@@ -1,2 +1,4 @@
target
work
/github-branch-source.iml
Copy link
Member

Choose a reason for hiding this comment

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

Suggesting install gitignore plugin if you are using IDEA or manually copy-paste IDEA, maven, java, eclipse, gradle (for future) ignores from https://github.com/github/gitignore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KostyaSha The .gitignore already existed. I've added only two new entries.

Copy link
Member

Choose a reason for hiding this comment

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

You and new contributors will change gitignore every time and it will be infinitely. Better add all required at once ;)

Copy link
Member

Choose a reason for hiding this comment

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

should be *.iml

@KostyaSha
Copy link
Member

Console output example

Is it a bug or fixed version?

@recena
Copy link
Contributor Author

recena commented Oct 28, 2015

@KostyaSha Please, give me some minutes to fill the JIRA issue.

return null;
}
listener.getLogger().format("Connecting to %s using %s%n", getDescriptor().getDisplayName(), CredentialsNameProvider.name(credentials));
GitHub github = Connector.connect(apiUri, credentials);
Copy link
Member

Choose a reason for hiding this comment

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

Sorry what does this method do? If you are using github-plugin integration, then you don't need it's credentials as they should be set only globally.

If it about git, then github token can't work with git://

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KostyaSha This plugin manages its own credentials, you can find other example. Additionally, we are using only https because the GH API is exposed through https.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/AbstractGitHubSCMSource.java#L202-L210
This i fixed in github-api long time ago.

Using login+password for github is unsecure and wrong, but for hacky plugin will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KostyaSha Why do you think it is using login+password and not login + apiToken?

Copy link
Member

Choose a reason for hiding this comment

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

Because in Connector i see standardUserCredentials

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can use that implementation for login + apiToken.

Copy link
Member

Choose a reason for hiding this comment

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

Token doesn't require login existence AFAIK

@jglick jglick changed the title [WiP] Retrieve method was implemented using GH API Retrieve method was implemented using GH API Oct 28, 2015
@@ -88,6 +88,10 @@
listener.getLogger().format(" %d branches were processed%n", branches);
}

@Override protected SCMRevision doRetrieve(SCMHead head, TaskListener listener, GHRepository repo) {
return new SCMRevisionImpl(head, "heads/" + head.getName());
Copy link
Member

Choose a reason for hiding this comment

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

🐛 you need to specify the actual commit hash here. Otherwise what would be the point?

@jenkinsadmin
Copy link
Member

Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests

@recena recena changed the title Retrieve method was implemented using GH API [JENKINS-31319] Retrieve method was implemented using GH API Oct 30, 2015
}

protected abstract SCMRevision doRetrieve(SCMHead head, TaskListener listener, GHRepository repo) throws IOException;
Copy link
Member

Choose a reason for hiding this comment

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

Not binary compatible, though I guess we do not care at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have only a beta release with 13 days 😵

Copy link
Member

Choose a reason for hiding this comment

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

And no coding styles for future trashing ;)

Copy link
Member

Choose a reason for hiding this comment

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

Actually we do care. This should fall back to a compatible behavior:

Selector selector = SCMHeadObserver.select(head);
doRetrieve(selector, listener, repo);
return selector.result();

@jglick
Copy link
Member

jglick commented Nov 2, 2015

🐝

@jglick
Copy link
Member

jglick commented Nov 2, 2015

Subsumed by #5. (Merging that would merge this automatically.)

@jglick jglick merged commit a49806f into jenkinsci:master Nov 2, 2015
@recena recena deleted the CJP-3205 branch November 5, 2015 23:51
stephenc added a commit that referenced this pull request Jul 10, 2017
[SECURITY-527] Enforcing USE_ITEM and @RequirePOST.
dubrsl pushed a commit to dubrsl/github-branch-source-plugin that referenced this pull request Oct 17, 2020
[JENKINS-57751] Fix config and code refractory
@jtnord jtnord mentioned this pull request Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants