Guest User

Untitled

a guest
Oct 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import com.cloudbees.plugins.credentials.*
  2. import com.cloudbees.plugins.credentials.common.*
  3. def credential_id = 'test'
  4. def id_matcher = CredentialsMatchers.withId(credential_id)
  5. def available_credentials = CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), null, null)
  6.  
  7.  
  8. String streamToSring(InputStream input) {
  9. Scanner s = new Scanner(input);
  10. StringBuilder builder = new StringBuilder();
  11. while (s.hasNextLine()) {
  12. builder.append(s.nextLine() +"\n");
  13. }
  14. return builder.toString();
  15. }
  16.  
  17. println streamToSring(CredentialsMatchers.firstOrNull(available_credentials, id_matcher).getContent())
Add Comment
Please, Sign In to add comment