这将是直接的,安装组件并从 Jenkins 发出 CLI 命令,以发出构建报告的 JIRA JQL 请求。但是,所有使用此插件的示例都使用旧的用户 ID/密码,该用户 ID/密码现在已被 GPRD 策略阻止。
~/.jira-cli.json
{"protocol":"https",
"host":"concentrixdev.atlassian.net",
"user":"Buildmaster", "password":"**********",
"apiVersion":"2","strictSSL":true}
Jenkinsfile
pipeline {
agent any
stages {
stage('Report') {
steps {
echo 'Creating JIRA report ...... commit msg leads with a JIRA keyword.'
echo 'Looking for JIRA, BUGS-773'
sh "jira version"
sh "jira search"
}
}
}
}
Jenkins 控制台输出
Started by user Build Master
> git rev-parse --resolve-git-dir /Users/devadmin/.jenkins/caches/git-5fa796c794a774e51c576b8e5620d019/.git # timeout=10
Setting origin to https://bitbucket.org/rjames2/jenkins-mobile-cicd.git
> git config remote.origin.url https://bitbucket.org/rjames2/jenkins-mobile-cicd.git # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git --version # timeout=10
> git --version # 'git version 2.24.3 (Apple Git-128)'
> git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials Build Master access to bitbucket.
> git fetch --tags --force --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
Seen branch in repository origin/feature/jira_jql
Seen branch in repository origin/master
Seen 2 remote branches
Obtained Jenkinsfile from aa3e9eb282a135cee8332527a2656bf24bdb03ce
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /Users/devadmin/.jenkins/workspace/test_jira_jql_feature_jira_jql
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential Buildmaster
> git rev-parse --resolve-git-dir /Users/devadmin/.jenkins/workspace/test_jira_jql_feature_jira_jql/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://bitbucket.org/rjames2/jenkins-mobile-cicd.git # timeout=10
Fetching without tags
Fetching upstream changes from https://bitbucket.org/rjames2/jenkins-mobile-cicd.git
> git --version # timeout=10
> git --version # 'git version 2.24.3 (Apple Git-128)'
using GIT_ASKPASS to set credentials Build Master access to bitbucket.
> git fetch --no-tags --force --progress -- https://bitbucket.org/rjames2/jenkins-mobile-cicd.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Checking out Revision aa3e9eb282a135cee8332527a2656bf24bdb03ce (feature/jira_jql)
> git config core.sparsecheckout # timeout=10
> git checkout -f aa3e9eb282a135cee8332527a2656bf24bdb03ce # timeout=10
Commit message: "BUGS-773 try a clean run."
> git rev-list --no-walk 90697d2dd36e301c1413087c92bb152dc6e7800f # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Report)
[Pipeline] echo
Creating JIRA report ...... commit msg leads with a JIRA keyword.
[Pipeline] echo
Looking for JIRA, BUGS-773
[Pipeline] sh
+ jira version
1.2.2
[Pipeline] sh
+ jira search
Error: Field 'summary' does not exist or this field cannot be viewed by anonymous users.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
REST API
Jenkins 2.277.2