jenkins获取添加的gitlabApiToken

2022-06-23  本文已影响0人  87d6dc4b11a7
import com.cloudbees.plugins.credentials.CredentialsProvider
def credsList = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(com.cloudbees.plugins.credentials.Credentials.class,Jenkins.instance,null,null);
def creds = credsList.findResult { it.id == "<YOUR-CREDS-ID>" ? it : null }
println("apiToken: ${creds.apiToken}")

参考:https://issues.jenkins.io/browse/JENKINS-48552
https://github.com/jenkinsci/gitlab-plugin/issues/536

上一篇下一篇

猜你喜欢

热点阅读