Jira

From Omnia
Revision as of 16:11, 13 November 2017 by Kenneth (talk | contribs) (→‎Python)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Server Maintenance

Service:

service jira stop
service jira start
service jira restart

Log files:

/opt/atlassian/jira/logs/

Quick Installation

Application Installation

Documentation:

Download and install:

cd /opt/
wget http://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-6.2.5-x64.bin
sh ./atlassian-jira-6.2.5-x64.bin

Custom Install

Jira Installation - /opt/atlassian/jira
Jira Data - /var/atlassian/application-data/jira
Ports - HTTP: 8080, Control: 8005
Service - yes

MySQL Database Configuration

Documentation:

Install mysql:

yum install mysql-server
service mysqld start
chkconfig mysqld on
mysql -u root
mysql> CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on jiradb.* TO jiradb@'%' IDENTIFIED BY 'jiradb';
mysql> flush privileges;
mysql> SHOW GRANTS FOR jiradb;

If you want to clear mysql users:

mysql> use mysql
mysql> truncate user;
mysql> truncate host;
mysql> grant all on *.* to root@'%' with grant option;
mysql> flush privilges;

Increase System Resources

/opt/atlassian/jira/bin/setenv.sh

#JVM_SUPPORT_RECOMMENDED_ARGS=""
JVM_SUPPORT_RECOMMENDED_ARGS="-Datlassian.plugins.enable.wait=300"
#JVM_MINIMUM_MEMORY="384m"
JVM_MINIMUM_MEMORY="768m"
#JVM_MAXIMUM_MEMORY="768m"
JVM_MAXIMUM_MEMORY="2048m"
#JIRA_MAX_PERM_SIZE=384m
JIRA_MAX_PERM_SIZE=512m

MySQL Database Connector

Documentation:

MySQL Connector/J JDBC driver v5.1 - http://dev.mysql.com/downloads/connector/j

cd /opt/
wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.zip
unzip mysql-connector-java-5.1.30.zip
cp mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar /opt/atlassian/jira/lib/
service jira restart

Installation Wizard

Now access the server installation wizard:

http://myserver:8080/

init.d

For reference - /etc/init.d/jira (dead simple):

#!/bin/bash

# chkconfig: 2345 90 60

# JIRA Linux service controller script
cd "/opt/atlassian/jira/bin"

case "$1" in
    start)
        ./start-jira.sh
        ;;
    stop)
        ./stop-jira.sh
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
esac

SSL Proxy

Documentation:

server.xml:

<Service name="Catalina">
 
    <!-- Apache Proxy Connector with values for scheme, proxyName and proxyPort -->
        <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192"
            maxThreads="150" minSpareThreads="25" port="8080" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true" 
            scheme="https" proxyName="jira.atlassian.com" proxyPort="443"/> 
 
    <!-- Standard HTTP Connector -->
        <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192"
        maxThreads="150" minSpareThreads="25" port="8081" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"/>

Gmail SMTP

Configuring JIRA's SMTP Mail Server to Send Notifications - JIRA 6.3 EAP - Atlassian Documentation - https://confluence.atlassian.com/display/JIRA/Configuring+JIRA%27s+SMTP+Mail+Server+to+Send+Notifications

<Resource name="mail/GmailSmtpServer"
 auth="Container"
 type="javax.mail.Session"
 mail.smtp.host="smtp.gmail.com"
 mail.smtp.port="465"
 mail.smtp.auth="true"
 mail.smtp.user="myusername@gmail.com"
 password="mypassword"
 mail.smtp.starttls.enable="true"
 mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
/>
cd /opt/atlassian/jira
mv atlassian-jira/WEB-INF/lib/mail-1.4.5.jar lib/
mv atlassian-jira/WEB-INF/lib/activation-1.1.1.jar lib/

CC Field

How to use a Multi User Picker CC: Field to mimic adding "watchers" on issue creation.

1. Add a Multi User Picker custom field. We called ours CC: on http://support.atlassian.com.

http://www.atlassian.com/software/jira/docs/latest/customfields/addcustomfield.html

2. Add this to the default screen (or whichever screen you are using for issue creation).

3. Add this field in your project's permission scheme (e.g. Browse Projects, Add Comments, etc.) so the users added to CC: have the ability to view/comment on the issue.

4. Add this CC: field to your project's notification scheme so the users are notified on issue creation, update, comment, etc.

http://www.atlassian.com/software/jira/docs/latest/notification_schemes.html

Source:

Python

python jira

pip install jira

See also Python/Jira

python JIRA

# pip install JIRA

from jira.client import JIRA

options = {
  'server': 'https://jira.oeey.com'
}
jira = JIRA(options=options, basic_auth=('kenneth', 'password'))    # a username/password tuple

issues = jira.search_issues('status != Closed AND status != Done AND assignee = currentUser() ORDER BY updated DESC, key DESC')

for issue in issues:
    print issue, "-", issue.fields.summary, "-", issue.fields.updated.split('T')[0]


import urllib
import requests
import xml.etree.ElementTree as ET

def query(query, server='https://jira.oeey.com', user='kenneth', pw='password'):
    jql_query = urllib.quote(query)
    query_url = (server + '/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=' + jql_query)
    req = requests.get(query_url, auth=(user, pw))
    req.raise_for_status()
    text = req.text.encode('ascii', 'ignore')
    root = ET.fromstring(text)
    return [x.text for x in root.findall("./channel/item/key")]

print query("text ~ 'some text'")

API

JIRA REST APIs - Atlassian Developers - https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis

Agile API

JIRA Software REST API Reference - https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0

Rename Sprint

Haven't found a way to rename a completed sprint from the GUI [1]

https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/sprint-updateSprint

#!/bin/bash

USERNAME="username"
PASSWORD="password"
URL="https://jira.oeey.com"
SPRINTID="111"
NEW_SPRINT_NAME="New Sprint Name"
NEW_START_DATE="8/Aug/16 8:00 PM"
NEW_END_DATE="9/Aug/16 1:18 PM"

curl -i -u$USERNAME:$PASSWORD "$URL/rest/greenhopper/1.0/sprint/$SPRINTID" -X PUT -H 'Accept: application/json, text/javascript, */*; q=0.01' \
 -H 'Accept-Language: pl,en-us;q=0.7,en;q=0.3' -H 'Connection: keep-alive' -H 'Content-Type: application/json; charset=UTF-8' \
 --data "{\"name\":\"$NEW_SPRINT_NAME\",\"startDate\":\"$NEW_START_DATE\",\"endDate\":\"$NEW_END_DATE\"}"

Delete Sprint

Haven't found a way to delete a completed sprint from the GUI

https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/sprint-deleteSprint

#!/bin/bash

USERNAME="username"
PASSWORD="password"
URL="https://jira.oeey.com"
SPRINTID="111"

curl -i -u$USERNAME:$PASSWORD "$URL/rest/greenhopper/1.0/sprint/$SPRINTID" -X DELETE -H 'Accept: application/json, text/javascript, */*; q=0.01' \
 -H 'Accept-Language: pl,en-us;q=0.7,en;q=0.3' -H 'Connection: keep-alive' -H 'Content-Type: application/json; charset=UTF-8'

keywords