我有多个使用管道脚本的Jenkins作业,我对其中至少4个使用相同的方法
event_text = event_text[-SCREEN_SIZE[1]/font_height:]
如何让每个管道作业导入此方法,以便如果我需要更新它,我可以只执行一次,此处的关键部分是能够使用def createJiraLinks(def ticketNumbers) {
ArrayList<String> jiraLinks = new ArrayList<String>();
for(int i =0; i < ticketNumbers.size(); i++) {
def jira_json = sh script: """/usr/local/bin/curl -X GET -H "Content-Type: application/json" --cert-type PEM --key-type PEM -E /Users/Jenkins/.jenkins/workspace/certificates/cert.pem --key /Users/Jenkins/.jenkins/workspace/certificates/cert.pem https://jira.dev.org.co.uk:443/rest/api/2/issue/${ticketNumbers[i]}""", returnStdout: true
def json = jsonParse(jira_json);
def summary = json['fields']['summary'].toString();
jiraLinks.add("[" + ticketNumbers[i] + "](https://jira.dev.org.co.uk/browse/" + ticketNumbers[i] + ")" + " - " + summary);
}
return jiraLinks;
}
,就像我运行curl命令使用sh script:
命令失败,因为我无法正确格式化
任何有关建议/提示
由于