Forked from chrisvire/jenkins-setup-credentials.groovy
Created
October 18, 2016 20:22
-
-
Save technolo-g/c75f8c3ededdf83512e6773eb2b96f60 to your computer and use it in GitHub Desktop.
Revisions
-
chrisvire revised this gist
Nov 24, 2015 . 1 changed file with 12 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,10 @@ import com.cloudbees.jenkins.plugins.sshcredentials.impl.* import org.jenkinsci.plugins.plaincredentials.* import org.jenkinsci.plugins.plaincredentials.impl.* import hudson.util.Secret import hudson.plugins.sshslaves.* import org.apache.commons.fileupload.* import org.apache.commons.fileupload.disk.* import java.nio.file.Files domain = Domain.global() store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore() @@ -34,17 +36,20 @@ CredentialsScope.GLOBAL, "secret-text", "Secret Text Description", Secret.fromString("some secret text goes here")) factory = new DiskFileItemFactory() dfi = factory.createItem("", "application/octet-stream", false, "filename") out = dfi.getOutputStream() file = new File("/path/to/some/file") Files.copy(file.toPath(), out) FileCredentailsImpl can take a file from a do secretFile = new FileCredentialsImpl( CredentialsScope.GLOBAL, "secret-file", "Secret File Description" dfi, // Don't use FileItem "", "") store.addCredentials(domain, priveteKey) -
chrisvire revised this gist
Nov 10, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ secretText = new StringCredentialsImpl( CredentialsScope.GLOBAL, "secret-text", "Secret Text Description", Secret.fromString("some secret text goes here")) file = new File("/path/to/some/file") noFileItem = [ getName: { return "" } ] as FileItem -
chrisvire revised this gist
Nov 10, 2015 . 1 changed file with 25 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,10 @@ 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.* import org.jenkinsci.plugins.plaincredentials.* import org.jenkinsci.plugins.plaincredentials.impl.* import hudson.util.Secret import org.apache.commons.fileupload.*; import hudson.plugins.sshslaves.*; domain = Domain.global() @@ -25,5 +29,25 @@ usernameAndPassword = new UsernamePasswordCredentialsImpl( "jenkins" ) secretText = new StringCredentialsImpl( CredentialsScope.GLOBAL, "secret-text", "Secret Text Description", Secret.fromString("some secret text goes")) file = new File("/path/to/some/file") noFileItem = [ getName: { return "" } ] as FileItem FileCredentailsImpl can take a file from a do secretFile = new FileCredentialsImpl( CredentialsScope.GLOBAL, "secret-file", "Secret File Description" noFileItem, // Don't use FileItem file.getName(), file.text) store.addCredentials(domain, priveteKey) store.addCredentials(domain, usernameAndPassword) store.addCredentials(domain, secretText) store.addCredentials(domain, secretFile) -
iocanel created this gist
Sep 1, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import jenkins.model.* 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.* import hudson.plugins.sshslaves.*; domain = Domain.global() store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore() priveteKey = new BasicSSHUserPrivateKey( CredentialsScope.GLOBAL, "jenkins-slave-key", "root", new BasicSSHUserPrivateKey.UsersPrivateKeySource(), "", "" ) usernameAndPassword = new UsernamePasswordCredentialsImpl( CredentialsScope.GLOBAL, "jenkins-slave-password", "Jenkis Slave with Password Configuration", "root", "jenkins" ) store.addCredentials(domain, priveteKey) store.addCredentials(domain, usernameAndPassword)