Created
March 28, 2016 06:14
-
-
Save grawert/6a647e32dc56acf4a165 to your computer and use it in GitHub Desktop.
Add direct SSH credentials to Jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.common.* | |
import com.cloudbees.plugins.credentials.domains.* | |
import com.cloudbees.plugins.credentials.impl.* | |
import com.cloudbees.jenkins.plugins.sshcredentials.impl.* | |
credentials = new BasicSSHUserPrivateKey( | |
CredentialsScope.GLOBAL, | |
"", | |
"username_HERE", | |
new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource( | |
"-----BEGIN RSA PRIVATE KEY-----\/-----END RSA PRIVATE KEY-----" | |
), | |
"", | |
"Description HERE" | |
) | |
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore() | |
store.addCredentials(Domain.global(), credentials) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment