ghprb-plugin
ghprb-plugin copied to clipboard
Configuring Github deploy key as the credential
Hi,
I've a repository with a few deploy keys created for it. These are meant to be used by CI.
Currently, I create the credentials like this:
import jenkins.model.*
import org.jenkinsci.plugins.ghprb.*
import hudson.util.Secret
[..]
GhprbTrigger.DescriptorImpl descriptor = Jenkins.instance.getDescriptorByType(org.jenkinsci.plugins.ghprb.GhprbTrigger.DescriptorImpl.class)
List<GhprbGitHubAuth> githubAuths = descriptor.getGithubAuth()
String serverAPIUrl = 'https://api.github.com'
String jenkinsUrl = '<our url>'
String credentialsId = 'GHPRB credentials ID'
String description = 'GHPRB'
String id = 'GHPRB credentials ID'
String secret = keyContent
githubAuths.add(new GhprbGitHubAuth(serverAPIUrl, jenkinsUrl, credentialsId, description, id, Secret.fromString(keyContent)))
descriptor.save()
keyContent is a SSH key retrieved from AWS secretsmanager.
This doesn't seem to work however - the requests hang for a long while until they fail.
I've a few questions.
- How might I configure a deploy key properly for GHPRB?
- Can I use BasicSSHUserPrivateKey from the SSH Credentials plugins or can I use credentials stored in that plugin, and if so, how?
- How do I make the credential I add above the default? Right now this just adds the credential to the end of the credentials for GHPRB. Each time I run this, it creates new credentials which is not what I want. Rather I just want to create a set of credentials once via code.