-1

在我的 Jenkinsfile 中,我想向 JIRA 查询一些特定数据,例如已发布版本的列表。此外,我想为特定版本创建票证。

我知道的 JIRA 插件,我们可以做一些事情,比如发布版本或更新问题,但不是我提到的事情。是否可以从 Groovy 脚本中调用 JIRA REST API 并以某种方式使用 Jenkins 配置中提供的 JIRA 凭据来解决问题?

4

1 回答 1

1

您可以使用 withCredentials()

withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
  set +x
  curl -u $USERNAME:$PASSWORD https:jira**** > output.json
  }

注意:如果您的密码或用户名有特殊字符,请在传递前对其进行编码

String encoded_password = java.net.URLEncoder.encode(env.PASSWORD, "UTF-8")

所需插件:https ://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin

于 2016-09-20T18:23:48.283 回答