[JIRA] (JENKINS-37864) Provide some mechanism for looking up whether credentials exist in Pipeline

2 views
Skip to first unread message

tyler@monkeypox.org (JIRA)

unread,
Aug 31, 2016, 1:25:01 PM8/31/16
to jenkinsc...@googlegroups.com
R. Tyler Croy created an issue
 
Jenkins / Improvement JENKINS-37864
Provide some mechanism for looking up whether credentials exist in Pipeline
Issue Type: Improvement Improvement
Assignee: Jesse Glick
Components: credentials-binding-plugin
Created: 2016/Aug/31 5:24 PM
Priority: Minor Minor
Reporter: R. Tyler Croy

In my use-case, I need to use the same Jenkinsfile on multiple Jenkins instances. The only differentiation between the two are the credentials which are available for use. (Basically, one instance is authorized for deployments, thus the credentials, the other is not).

My ideal would be a credentials global variable, or something like that, which could have utility methods like this. E.g.

node {
  if (credentials.lookup('some-credentials-id')) {
    withCredentials('some-credentials-id') {
      sh './deploy.sh'
    }
  }
}

Related to JENKINS-37863

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Nov 7, 2016, 4:47:01 PM11/7/16
to jenkinsc...@googlegroups.com
Jesse Glick commented on Improvement JENKINS-37864
 
Re: Provide some mechanism for looking up whether credentials exist in Pipeline

I suppose you could say, for example

boolean stringCredentialsExist(String id) {
  try {
    withCredentials([string(credentialsId: id, variable: 'irrelevant')]) {
      true
    }
  } catch (_) {
    false
  }
}

pieter@pietervogelaar.nl (JIRA)

unread,
Jun 18, 2019, 8:55:02 AM6/18/19
to jenkinsc...@googlegroups.com

Jesse Glick Thanks, that example worked great!

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages