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

Task/jenkins 42120 git creation credential changes #895

Merged
merged 40 commits into from
Mar 16, 2017

Conversation

cliffmeyers
Copy link
Contributor

@cliffmeyers cliffmeyers commented Mar 9, 2017

Description

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Appropriate unit or acceptance tests or explanation to why this change has no tests
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.
  • Ran Acceptance Test Harness against PR changes.

Reviewer checklist

  • Run the changes and verified the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Vivek Pandey and others added 25 commits January 27, 2017 11:39
- Don't create org folder if there was error
- collect various 400 errors and return in same response
…tive primarily) were showing through the modal due to opacity / stack order
…-changes

# Conflicts:
#	blueocean-dashboard/src/main/less/creation/git.less
#	blueocean-dashboard/src/main/resources/jenkins/plugins/blueocean/dashboard/Messages.properties
…n-credential-changes

# Conflicts:
#	blueocean-commons/src/main/java/io/jenkins/blueocean/commons/ErrorMessage.java
#	blueocean-github-pipeline/src/main/java/io/jenkins/blueocean/blueocean_github_pipeline/GithubPipelineCreateRequest.java
…n errors returned from "create" REST API; errors other than "name conflict" are displayed in error step with extra info for debugging
…n-credential-changes

# Conflicts:
#	blueocean-commons/src/main/java/io/jenkins/blueocean/commons/ErrorMessage.java
#	blueocean-github-pipeline/src/main/java/io/jenkins/blueocean/blueocean_github_pipeline/GithubPipelineCreateRequest.java
…equired" to a "credentialId" error rather than "uri" error
…ng to invalid URL and invalid credential errors
@michaelneale
Copy link
Member

michaelneale commented Mar 10, 2017

  • There is no "use system ssh" any more? (I think in ticket it says don't need to use that, but not sure if that is valid...). But I am not sure what it meant in classic anyway so... maybe not a huge deal
  • I wasn't able to make it work with a private key and a git@url. I renamed my ~/.ssh/id_rsa to something so the system wouldn't pick it up - but pasting it in didn't work. That window is far too small for a private key (I am not sure if a dialog is the best for that) so I can't tell if something messed up formatting, but it didn't work.
  • I end up with lots of "michaelneale" named credentials in the list that I can't tell apart trying the above (no way to easily remove them)
  • I tried using username and password with git@ style - and it didn't work (should that case?)

So basically - I don[t think the git@ case is working in the current form for this at all.

HTTP case worked, but not git@.

@michaelneale
Copy link
Member

EDIT: in previous version, ssh private key didn't work correctly either. The easiest way to test is just to rename your ssh key in ~/.ssh so you know it isn't being used.

@michaelneale
Copy link
Member

michaelneale commented Mar 13, 2017

  • I tried the latest and it works with private key, however if I use "none" (the equivalent of system?) it says it is not a valid URL, but in the server log I see it is credentials related:
Mar 13, 2017 4:38:24 PM io.jenkins.blueocean.blueocean_git_pipeline.GitUtils validateCredentials
SEVERE: Error running git remote-ls: Cannot open session, connection is not authenticated.
java.lang.IllegalStateException: Cannot open session, connection is not authenticated.
	at com.trilead.ssh2.Connection.openSession(Connection.java:1127)

So this seems a regression from how it was previously, I would think?

This is one area where I think the lack of ATH/automated testing is slowing us down in moving it forward, unfortunately.

  • Also, once I pick a credential, I can't go back to "none".
  • The lack of meaningfully named credentials makes this a bit of a mess pretty quickly:
    screen shot 2017-03-13 at 5 15 46 pm

This may bite me more in testing as it is contrived, but it makes it pretty much impossible to reuse things (not part of this PR really - just is very apparent). I not longer reuse credentials as there are too many from my testing 😭

If you can make it work with system ssh - then might be close enough for rock n roll.

@cliffmeyers
Copy link
Contributor Author

@michaelneale good catches. Will look into the validation field mismatch. The "none" option was a bad assumption on my part about how to handle it, will fix that too.

Realized also that Dropdown needs a couple of tweaks to really polish it up, so I'm going to do that today too in a separate JDL PR.

Cliff Meyers added 2 commits March 13, 2017 15:04
…t authenticated" error message into a validation error against the credentialId
@cliffmeyers
Copy link
Contributor Author

@michaelneale both issues should now be fixed.

@michaelneale
Copy link
Member

michaelneale commented Mar 14, 2017

@cliffmeyers I still can't use git@github.com:multibranchorg/newbie.git

with the "none" credential - but it should default to using the system right?

Mar 14, 2017 11:30:40 AM io.jenkins.blueocean.blueocean_git_pipeline.GitUtils validateCredentials
SEVERE: Error running git remote-ls: Cannot open session, connection is not authenticated.
java.lang.IllegalStateException: Cannot open session, connection is not authenticated.
	at com.trilead.ssh2.Connection.openSession(Connection.java:1127)
	at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:32)
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:264)
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:162)
	at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:198)
	at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:159)
	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.getRemoteReferences(JGitAPIImpl.java:768)
	at io.jenkins.blueocean.blueocean_git_pipeline.GitUtils.validateCredentials(GitUtils.java:48)
	at io.jenkins.blueocean.blueocean_git_pipeline.GitPipelineCreateRequest.validate(GitPipelineCreateRequest.java:125)
	at io.jenkins.blueocean.blueocean_git_pipeline.GitPipelineCreateRequest.<init>(GitPipelineCreateRequest.java:45)

on server.

The error message is better now - says it is credential error vs url error... so that is good at least, but something isn't right with the system credential "none" option.

@michaelneale
Copy link
Member

michaelneale commented Mar 14, 2017

@cliffmeyers yes I confirmed with master that if it says "system" it would use my id_rsa as I expect, from disk, and I could clone private repos via ssh.

"none" in this case does not behave like that - is that intended?

@michaelneale
Copy link
Member

I checked with classic, and "none" actually means none - ie it will delegate to the id on the system via the git client, not jenkins internal key.

So this is not consistent behavior with previous master or classic - @vivek may need to tweak that assuming it is on the server side (probably is).

@i386
Copy link
Contributor

i386 commented Mar 14, 2017

@cliffmeyers where does the name 'none' come from? Can we make the name reflect what credential it is? It would be good to italicise its name in the dropdown to differentiate it from user defined credentials.

@i386 i386 mentioned this pull request Mar 14, 2017
8 tasks
@cliffmeyers
Copy link
Contributor Author

@i386 credential of "none" is exactly that: calling the creation API with a null credentialId. I can style the text no problem.

@MichaelNeal @i386 @vivek at this point I don't know exactly how to proceed. I guess we have the following questions:

  • When the user chooses "none", what does that mean? I took it as "no credential." If that's the case, we need to figure out why we receive a SSH error when trying to connect. @vivek is that expected? Do all SCM checkouts over SSH require that a public key be sent? I suppose they might, actually?
  • Should "none" actually use some other credential, transparent to the user? Would it be the master's "default SSH key"? If so, @vivek can you confirm that's the credential we needed to create via the REST API? And is that SSH key something that Jenkins is generating itself, or is that picking up the key from ~/.ssh?
  • Lastly, if the answer to the above is "no", then should we assume that any keys in ~/.ssh should never automatically be picked up by Jenkins SCM operations?

@vivek
Copy link
Collaborator

vivek commented Mar 14, 2017

If that's the case, we need to figure out why we receive a SSH error when trying to connect. @vivek is that expected? Do all SCM checkouts over SSH require that a public key be sent? I suppose they might, actually?

Thats right, if you access git over ssh protocol, you need to provide your ssh keys, even for public repos.

Should "none" actually use some other credential, transparent to the user? Would it be the master's "default SSH key"? If so, @vivek can you confirm that's the credential we needed to create via the REST API? And is that SSH key something that Jenkins is generating itself, or is that picking up the key from ~/.ssh?

I am confused. Just send null credentialId if user doesn't provide any credential, then all the defaulting behavior will be as per underlying branch-source plugin.

Lastly, if the answer to the above is "no", then should we assume that any keys in ~/.ssh should never automatically be picked up by Jenkins SCM operations?

Check the classic defaulting behavior thats what will happen in this case as well.

@cliffmeyers
Copy link
Contributor Author

@vivek thanks, this makes sense now. I will follow up with a side conversation to get UI nailed down.

@michaelneale
Copy link
Member

@cliffmeyers @vivek I think "none" (even if we tweak the exact name) should work the same as running:

"git clone git@thing.com/bar.git"

ie, it is up to my system config to decide what public key to use (for me that is ~/.ssh/config - which says to use id_rsa for github.com addresses).

Not sure if it shoudl be called "none" or something else, but that would make it consistent at least.

Cliff Meyers added 2 commits March 15, 2017 13:22
…ion in credentials dropdown. will use no credential for HTTP/S URLs and will use "default system ssh" credential for all others
…de nixed Dropdown.selectOption method; instead use a small hack to alter the Dropdown's internal state
@cliffmeyers
Copy link
Contributor Author

@michaelneale ready for re-test now.

Cliff Meyers added 4 commits March 15, 2017 22:35
…-changes

# Conflicts:
#	blueocean-core-js/package.json
#	blueocean-dashboard/npm-shrinkwrap.json
#	blueocean-dashboard/package.json
#	blueocean-personalization/npm-shrinkwrap.json
#	blueocean-personalization/package.json
#	blueocean-web/npm-shrinkwrap.json
#	blueocean-web/package.json
@michaelneale
Copy link
Member

This will need a master bump to pass the ATH as there was a recent merge for functionality around artifacts and the ATH. This requires a small change in master behavior which is not here (hence ATH fails).

@michaelneale
Copy link
Member

@cliffmeyers if you update to master to get ATH to pass - I think this can go in if it sniffs ok. Assume a 🐝 if all checks out.

@cliffmeyers
Copy link
Contributor Author

@cliffmeyers cliffmeyers merged commit 4c3f296 into master Mar 16, 2017
@cliffmeyers cliffmeyers deleted the task/JENKINS-42120-git-creation-credential-changes branch March 16, 2017 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants