30 Nisan 2013 Salı

Delete issues from JIRA


  • Go to issue navigator
  • Under tools at the right hand side, bulk operations
  • choose the issues you want to delete
  • Confirm the deletion


27 Kasım 2012 Salı

JIRA REST API - Updating Status

You can change a status with executing the transition.

  • You should give the transition id. "{transition\": {\"id\": \"61\"}"
  • The url should be :  "http://localhost:8080/rest/api/2/issue/TAI-39/transitions?expand=transitions.fields" SElect the issue that you want to update.
  • You shoul use "POST"
  • Here is the curl command: curl -D- -X POST -H "Authorization: Basic YWRtaW46SDF0MXQ=" --data "{\"transition\": {\"id\": \"81\"}}" -H "Content-Type: application/json" "http://localhost:8080/rest/api/2/issue/TAI-39/transitions?expand=transitions.fields"
  • Here is the java implementation:          
  •                                                                
    public static String httpGet() throws IOException {         
    URL url = new URL("http://localhost:8080/rest/api/2/issue/TAI-39/transitions?expand=transitions.fields");         
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();  
    conn.setDoOutput(true);         
    conn.setDoInput(true);                 
    String credentials = "username" + ":" + "password";        
     String encoding = Base64Converter.encode(credentials.getBytes("UTF-8"));   
    conn.setRequestProperty("Authorization", String.format("Basic %s", encoding));  
    conn.setRequestMethod("POST"); 
    conn.setRequestProperty("Content-Type", "application/json");    
      conn.connect();                  
     String st = "{\"transition\": {\"id\": \"91\"}}";    
     System.out.println(st);      
      byte[] outputBytes = st.getBytes("UTF-8");     
     OutputStream os = conn.getOutputStream();  
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));        
     StringBuilder sb = new StringBuilder();        
     String line;         
    while ((line = rd.readLine()) != null) {           
    sb.append(line);         
    }         
    rd.close();             
    conn.disconnect();        
    System.out.println("sb: "+ sb.toString());         
    return sb.toString();     
    }

JIRA REST API - Edit Issues


  • When you want to update a field with JIRA REST API, first write it i json format.  Ex: I want to update the summary of an issue.        
  • {"fields": {"summary":{"name":"bahar"}}}
  •  You can try it with curl commant whether it works or not.
  •   curl -D- -X PUT -H "Authorization: Basic YWRtaW46SDF0MXQ=" --data "{\"fields\":{\"summary\":\"bahar\"}}"   -H "Content-Type: application/json" "http://localhost:8080/rest/api/2/issue/TAI-9"
  •  You should use PUT for updating.
  • Don't forget to add "\" backslash  before the double quotes.
  • You should encode your username:password with base 64 encode.
  • encoder 
  • write your username:password, and the output will be "YWRtaW46SDF0MXQ= " something like this. Write the output to the authorization. 
  • Ex: "Authorization: Basic YWRtaW46SDF0MXQ="  
  • "http://localhost:8080/rest/api/2/issue/TAI-9" is the issue that you want to update.
  •   You can do the same thing with java code.Here is the method:   
     public static String updateSummary() throws IOException {
     
        URL url = new URL("http://localhost:8080/rest/api/2/issue/TAI-9");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setDoInput(true);

        String credentials = "username" + ":" + "password";
        String encoding = Base64Converter.encode(credentials.getBytes("UTF-8"));
        conn.setRequestProperty("Authorization", String.format("Basic %s", encoding));
       
        conn.setRequestMethod("PUT");
        conn.setRequestProperty("Content-Type", "application/json");
       
        conn.connect();
      
        String st="{\"fields\":{\"summary\":\"bahar\"}}"

        byte[] outputBytes = st.getBytes("UTF-8");
        OutputStream os = conn.getOutputStream();
        os.write(outputBytes);
        os.flush();
       
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = rd.readLine()) != null) {
          sb.append(line);
        }
        rd.close();

        conn.disconnect();
        return sb.toString();

    }                                                                                                                               

  • you can use Base64Convertor.java class. Download
  • Here is the atlassian documentation for updating issue via JIRA REST API. atlassian

8 Kasım 2012 Perşembe

JIRA - Create Custom Fields with Code

You can automatically create custom fields with code within your plugin for JIRA.
Here is an  example method to do this. This method creates four custom fields.

public void createAllCustomFields(){
        CustomFieldType fieldType = customFieldManager.getCustomFieldType("com.atlassian.jira.plugin.system.customfieldtypes:textfield");
        try {
            CustomField contactName = customFieldManager.createCustomField("Contact Name", "Name of the contact", fieldType , null, null, null);
            customFieldManager.createCustomField("Contact Surname", "Surname of the contact", fieldType , null, null, null);
            customFieldManager.createCustomField("Contact Phone", "Phone number of the contact", fieldType , null, null, null);
            customFieldManager.createCustomField("Contact Email", "Email address of the contact", fieldType , null, null, null);
        } catch (GenericEntityException e) {
       
            e.printStackTrace();
        }
        System.out.println("createAllCustomFields is called !!!!!!!!!!!!!!!!!!!!!");
    }

Plugin Development Tips


2 Kasım 2012 Cuma

Create some marketing materials












 
 plugin logo














A plugin logo that is a 72x72px PNG/JPG/GIF image. Atlassian strongly recommends a chiclet-style background for the logo (check out this free Photoshop template). This format works best with upcoming changes to the user interfaces of UPM and the Atlassian Marketplace.
plugin icon The plugin icon that is a 16x16px PNG/JPG/GIF pixel version of your plugin logo or an appropriate derivation of it.
banner

Currently, UPM 2.0 does not display banners but later versions will. Moreover, a banner is required by the Atlassian Marketplace. So, since ArfX's functionality (nothing really) is likely to work in future versions of both JIRA and UPM, this example adds a banner to show up when the software supports it. 

Here is how to add it to your plugin

Plugin Metadata Files used by UPM and Marketplace


Velocity Guide

Velocity is a Java-based template engine. It permits web page designers to reference methods defined in Java code. Web designers can work in parallel with Java programmers to develop web sites according to the Model-View-Controller (MVC) model, meaning that web page designers can focus solely on creating a well-designed site, and programmers can focus solely on writing top-notch code. Velocity separates Java code from the web pages, making the web site more maintainable over the long run and providing a viable alternative to JSPs.

Velocity - Guide

<HTML>
<BODY>
Hello $customer.Name!
<table>
#foreach( $mud in $mudsOnSpecial )
   #if ( $customer.hasPurchased($mud) )
      <tr>
        <td>
          $flogger.getPromo( $mud )
        </td>
      </tr>
   #end
#end
</table>