We normally interact with JIRA via the browser. Sometimes, it is useful to be able to use the command line, especially for administrative tasks or writing shell scripts.
In this recipe, we will use the command line to create new users in JIRA.
For this recipe, you need to have the Atlassian Command Line Interface (CLI) tool available on your workstation. You can download it from the following link:
To use the Atlassian CLI tool, we first need to enable the Remote API from JIRA:
You then need to install the Atlassian CLI tool by unzipping it to a convenient location on your workstation. Next, update the jira.sh
(for UNIX) or jira.bat
(for Windows) file to add in JIRA's details.
For example, as shown in the following command, JIRA is running on
http://localhost:8080
, and the administrator credential is admin_user
with admin_password
as the password:
java -jar 'dirname $0'/lib/jira-cli-3.8.0.jar
-server http://localhost:8080 --user admin_user
--password admin_password "$@"
./jira.sh --action addUser --userId tester
-userEmail [email protected] --userFullName
Tester
User: tester added with password:
89u66p3mik5q. Full name is: Tester. Email is:
[email protected].
The Atlassian CLI tool works by accessing JIRA features via its Remote SOAP and REST API, which need to be enabled first.
We updated the JIRA script file with JIRA details, so we don't have to specify them every time; this is useful if we want to use the tool in a script. When we run the JIRA script, it will have all the necessary connection information.
The Atlassian CLI comes with a list of command actions such as the addUser
action that we used to create users in JIRA. You can get a full list of actions from the following link:
https://bobswift.atlassian.net/wiki/display/JCLI/Documentation