jenkins-pipeline - 如何使用 Jenkins 声明性脚本获取 JIRA 票号
问题描述
如何使用 Jenkins Pipeline 脚本获取 JIRA 票号示例:
CICD-34
以下命令提供了有关票证的完整信息,但我们如何仅获取 ID 并将其存储在变量中?
def issue = jiraJqlSearch jql: 'PROJECT = CICD AND description~"New JIRA Created from Jenkins through Declarative PL script"', site: 'MyLocalJira'”<br> echo issue.data.toString()
解决方案
我有同样的问题并找到解决方案。我和你分享我的答案:)
def testExecutionSearch = jiraJqlSearch jql: "project=${project} and issuetype = 'Test Execution' and summary ~ '${summary}'", site: 'myjira', failOnError: true
if (testExecutionSearch != null){
//Get all issues
def issues = testExecutionSearch.data.issues
//Get the key of the first result
def key = issues[0].key
}
在这里,我采用 jql 搜索的第一个元素(def key = issues[0].key),但你可以选择你想要的:)
推荐阅读
- azure - 使用错误版本的包的 Azure DevOps 构建解决方案
- spring - 无法决定我应该使用哪个 Spring Boot 版本?
- node.js - Socket.io ID 和用户信息安全
- jquery - 显示来自 json 的图像和标题,但消息说无法读取未定义的属性“图像”
- javascript - 使用某些过滤器检索 n 个随机文档 MongoDB
- r - 如何编号唯一对 X,Y
- c# - 在 Xamarin C# Visual Studio 中创建 TableView
- javascript - 如何使用javascript集成字符串中字符的计数频率
- c# - 始终使用最新版本的 Newtonsoft.Json
- c# - 无法首先在列实体框架代码上定义 PRIMARY KEY 约束