vfcps-qacoe-jiraclient v1.0.3
JiraClient
jiraclient is a command line tool for Atlassian Jira that was created for the purpose to simplify integration into CI/CD piplelines, in order to achieve tasks such as
- Update ticket statuses
- Link commits to Jira Tickets,
Environment Variables:
The tool will require the following environment variables to be set:
- JIRA_HOST: hostname of the Jira instance ( typically "cps.jira.agile.vodafone.com")
- JIRA_USER: username to be used to authenticate against JIRA ( this will only work with functional accounts)
- JIRA_PWD: password to be used to authenticate against JIRA ( this will only work with functional accounts)
In case you don't have a functional account, see here how to request this,
Running the tool from this repository
The tool can be installed and run locally from source code, using the following sequence of commands:
$ npm install
$ npm install -g
$ jiraclient
Installation
The package is published to the Vodafone JFrog Artifact repository.
Warning At the moment, npm packages cannot be downloaded from JFrog Artifact repository if you are using npm v.8.x. In order to install the package, you might have to downgrade to npnm v.7 using
$ npm install npm@7
Local Installation
In order to install the package from the Vodafone JFrog Repository, you first need to register and login into the Artifact repository.
Please contact the QACOE team, in order to enable your account for the repository. Once your account is enabled, you can use the following commands to setup the registry:
$ npm config set @VFCPS:registry https://artifactory.vodafone.com/artifactory/api/npm/npm-vfgroup-cps-test-virtual/
$ npm login --scope @VFCPS
And now you can installthe tool, withthe following ommand:
$ npm install -g @VFCPS/jiraclient
Using in CI/CD pipeline step
As you are not able to perform the login step in a CI/CD pipeline step, you need to first create a .npmrc
file in the home directory of the user.
The content of the file should contain the following lines:
.... always-auth=true //artifactory.vodafone.com/artifactory/api/npm/> npm-vfgroup-cps-test-virtual/:username=${NPM_USERNAME} //artifactory.vodafone.com/artifactory/api/npm/npm-vfgroup-cps-test-virtual/:_password=${NPM_PASSWORD} @VFCPS:registry=https://artifactory.vodafone.com/artifactory/api/npm/npm-vfgroup-cps-test-virtual/ ...
Now you can setup username and password as secrets in your CI/CD and copy them into the environment variables NPM_USERNAME
and NPM_PASSWORD
Once that is done, you need to run the following commands to install the tool:
$ npm install npm@7
$ npm install -g @VFCPS/jiraclient
Commands
At the moment, the tools support the following commands:
getstatus
Outputs the current status of the ticket
Parameters:
- Ticket-ID
$ jiraclient getstatus QACOE-1234 Done
setstatus
updates the status of the ticket to the requested value.
Note The ticket will only be set to the requested state, if it has not yet reached the requested state ( e.g. if the workflow is backlog->in progres->done) and the ticket is on "done" state, setstatus "in progress"
would not update the ticket und the output would be no change
Parameters:
- Ticket-ID
- status
$ jiraclient setstatus QACOE-1234 "In Progress" no change
addcommit
Links a code commit or merge with a JIRA ticket, so that the ticket contains a change history
Parameters:
- Ticket-ID
- commit-url: Full URL of the commit/merge
- email: email address of the user performing commit/merge
$ jiraclient addcommit QACOE-1234 https://github.vodafone.com/VFCPS-QACOE/JiraClient/commit/4944df7bd55e317432cd3c2a22e9ba9f9397d8fe guido.doumen@vodafone.com https://cps.jira.agile.vodafone.com/rest/api/2/issue/QACOE-1234/remotelink/149000