Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Sometimes you need to repeat the same command multiple times, for example you may need to create a lot of users, projects etc. In this situation instead of running the command manually with different inputs, you can put all the information in an csv file (or you can export it from another system that supports csv CSV files) and execute the command in a loop. It sounds long but actually it is a single liner.

Assuming that the CSV file has the format:

Code Block
languagetext
displayName1,emailAddress1,password1,username1
displayName2,emailAddress2,password2,username2
....

You can use the following one-liner command in the terminal to create users for each line in the CSV file:

Code Block
languagebash
while IFS=',' read -r displayName emailAddress password username || [ -n "$displayName" ]; do jira user create --displayName "$displayName" --emailAddress "$emailAddress" --password "$password" --username "$username"; done < input.csv

Here's how this command works:

  • while IFS=',' read -r displayName emailAddress password username || [ -n "$displayName" ]; do reads each line from the CSV file and sets the values of displayName, emailAddress, password and username variables based on the comma-separated values in the line.

  • jira user create --displayName "$displayName" --emailAddress "$emailAddress" --password "$password" --username "$username" invokes the jira user create command with appropriate parameters for each line in the CSV file.

  • done < input.csv specifies the input file for the while loop. Here, input.csv is the name of the CSV file.

Note: You need to replace input.csv with the actual name of your CSV file.

This will create users from the file one by one and output user properties as it creates them.

Code Block
languagetext
 Account Id               Account Type Email Address         Display Name Active Time Zone       Locale 
 ──────────────────────── ──────────── ───────────────────── ──────────── ────── ─────────────── ────── 
 647629232c717c0510823122 atlassian    example@gmail.com     Walter White true   Europe/Helsinki en_US  

 Account Id               Account Type Email Address         Display Name Active Time Zone       Locale 
 ──────────────────────── ──────────── ───────────────────── ──────────── ────── ─────────────── ────── 
 9383737967102fc717c0510a atlassian    example2@gmail.com    Heisenberg   true   Europe/Helsinki en_US