Project

rujira

0.0
No release in over a year
The library is under development
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

RUJIRA

Ruby

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.

This project was created as an alternative to https://github.com/sumoheavy/jira-ruby, offering a more user-friendly and intuitive interface. It lets you work with requests as objects or hash arrays, provides flexibility in choosing a connection adapter, and makes the codebase easier to maintain.


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.7.0'

Or install directly:

gem install rujira

Quick Start

Configuration

 cat .env
RUJIRA_TOKEN='<TOKEN>'
RUJIRA_DEBUG=true
LOG_LEVEL=error

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 "file=@upload.png" -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