RUJIRA

RUJIRA is a Ruby gem for easy interaction with the Jira API. It provides a simple and flexible interface to work with Jira resources and includes Rake tasks for convenient command-line operations.


Features

  • Easy DSL for building and executing Jira API requests.
  • Built-in Rake tasks for console operations (e.g., creating issues, updating data, exporting).

Installation

Add to your Gemfile:

gem 'rujira', '~> 0.6.0'

Or install directly:

gem install rujira

Quick Start

Configuration

Example of usage

require 'date'

now = Date.today
before = now + 30

project = random_name
url = ENV.fetch('RUJIRA_URL', 'http://localhost:8080')
client = Rujira::Client.new(url, debug: true)

client.ServerInfo.get
name = client.Myself.get['name']

client.Project.create do
  payload key: project.to_s,
          name: project.to_s,
          projectTypeKey: 'software',
          lead: name
end
client.Project.get project.to_s
client.Issue.create do
  payload fields: {
    project: { key: project.to_s },
    summary: 'BOT: added a new feature.',
    description: 'This task was generated by the bot when creating changes in the repository.',
    issuetype: { name: 'Task' }
  }
  params updateHistory: true
end

client.Board.list
client.Board.get 1

sprint = client.Sprint.create do
  payload name: 'Bot Sprint',
          originBoardId: 1,
          goal: 'Finish core features for release 1.0',
          autoStartStop: false
end
client.Sprint.issue sprint['id'], ["#{project}-1"]

client.Sprint.replace sprint['id'] do
  payload state: 'future',
          name: 'Bot Sprint',
          originBoardId: 1,
          goal: 'Finish core features for release 1.0',
          startDate: now,
          endDate: before,
          autoStartStop: true
end

update = client.Sprint.update sprint['id'] do
  payload name: "Bot Sprint #{project}"
end
issues = client.Sprint.get_issue sprint['id']

client.Issue.get "#{project}-1"

client.Issue.watchers "#{project}-1", name
search = client.Search.get do
  payload jql: "project = #{project} and status IN (\"To Do\", \"In Progress\") ORDER BY issuekey",
          maxResults: 10,
          startAt: 0,
          fields: %w[id key]
end
client.Issue.comment "#{project}-1" do
  payload body: 'Adding a new comment'
end
client.Issue.edit "#{project}-1" do
  payload update: {
            labels: [{ add: 'bot' }, { remove: 'some' }]
          },
          fields: {
            assignee: { name: name },
            summary: 'This is a shorthand for a set operation on the summary field'
          }
end

sprints = client.Board.sprint 1
sprints['values'].each do |sprint|
  client.Sprint.delete sprint['id']
end
search['issues'].each do |issue|
  client.Issue.delete issue['id'] do
    params deleteSubtasks: true
  end
end
client.Project.delete project.to_s

client.Dashboard.list
client.Dashboard.get 10_000
  • The builder method automatically applies the authorization token.
  • The block allows customization of headers, parameters, and other request options.

Rake Tasks

The gem includes Rake tasks for easy use from the command line. Examples:

rake jira:board:get               # Get a board
rake jira:board:list              # Get list of boards
rake jira:board:sprint            # Get a boards sprint
rake jira:dashboard:get           # Get a dashboard
rake jira:dashboard:list          # Get list of dashboards
rake jira:issue:attach            # Example usage attaching in issue
rake jira:issue:create            # Create a issue
rake jira:issue:delete            # Delete issue
rake jira:issue:search            # Search issue by fields
rake jira:project:list            # Get list of projects
rake jira:server_info             # Test connection by getting server information
rake jira:sprint:properties:list  # Get sprint properties
rake jira:whoami                  # Test connection by getting username
rake jira:issue:create PROJECT=ITMG SUMMARY='The short summary information' \
      DESCRIPTION='The base description of task' ISSUETYPE='Task'
rake jira:issue:search JQL='project = ITMG'
rake jira:issue:attach FILE='upload.png' ISSUE_ID='ITMG-1'

Development runs

docker compose up -d
open http://localhost:8080

curl -H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" 'http://localhost:8080/rest/api/2/search?expand=summary'
curl -vv -X POST --data '"some"' -H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" -H "Content-Type: application/json" 'http://localhost:8080/rest/api/2/issue/ITMG-70/watchers'
curl -D- -F "[email protected]" -X POST -H "X-Atlassian-Token: nocheck" \
    -H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" 'http://localhost:8080/rest/api/2/issue/ITMG-70/attachments'


Contribution

  • Pull requests are welcome.
  • For issues or feature requests, please use GitHub Issues.

License

MIT License © 2025 iTmageLAB