Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENKINS-31755 / Correct README #5

Merged
merged 2 commits into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions README
@@ -1,15 +1,17 @@
This is a Jenkins plugin which updates issues in Jira (by changing their status and adding a comment) as part of a Jenkins job.
This is a Jenkins plugin which updates issues in Jira (by changing their status, adding a comment or updating field values) as part of a Jenkins job.

Possible scenarios in which you might want to use it:

- in case you would like to announce or just log in Jira that the deployment of certain fixes / issues the acceptance server has completed (this makes sense if you already use Jenkins to deploy your applications to the acceptance web/app server).
- in case you would like Jenkins to update multiple issues when a new version of one of your projects is released (this makes sense if you use the "maven release plugin" and you trigger it from Jenkins).
- in case you would like to progress multiple Jira issues in the workflow (bulk changing the status of multiple Jira issues) and/or add a comment to issues after a Jenkins job has successfully completed.
- in case you would like to update fields in the Jira
- (Currently not supported) in case you would like Jenkins to update multiple issues when a new version of one of your projects is released (this makes sense if you use the "maven release plugin" and you trigger it from Jenkins).

Inputs:

- the Jira SOAP URL (e.g. http://something.com/rpc/soap/jirasoapservice-v2)
- the Jira REST URL (e.g. http://something.com/rest/api/2)
- the Jira username and password to be used to connect to Jira
- a JQL query selecting the issues to be updated (e.g. project="JENKINS" and status="Pending deploy")
- the name of the workflow action to be executed (not mandatory)
- the message to be added to each issue (not mandatory)
- the message to be added (can use environment variable substitution) to each issue (not mandatory)
- The field name and value to be used (not mandatory)
6 changes: 3 additions & 3 deletions src/main/java/info/bluefloyd/jira/model/FieldSummary.java
Expand Up @@ -10,7 +10,7 @@
*/
public class FieldSummary {
private String summary;
private List<String> versions;
private List<VersionSummary> versions;

/**
* @return the summary
Expand All @@ -29,14 +29,14 @@ public void setSummary(String summary) {
/**
* @return the versions
*/
public List<String> getVersions() {
public List<VersionSummary> getVersions() {
return versions;
}

/**
* @param versions the versions to set
*/
public void setVersions(List<String> versions) {
public void setVersions(List<VersionSummary> versions) {
this.versions = versions;
}

Expand Down
103 changes: 103 additions & 0 deletions src/main/java/info/bluefloyd/jira/model/VersionSummary.java
@@ -0,0 +1,103 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package info.bluefloyd.jira.model;

/**
*
* @author ian
*/
public class VersionSummary {
private boolean archived;
private String description;
private String id;
private String name;
private boolean released;
private String self;

/**
* @return the self
*/
public String getSelf() {
return self;
}

/**
* @param self the self to set
*/
public void setSelf(String self) {
this.self = self;
}

/**
* @return the archived
*/
public boolean isArchived() {
return archived;
}

/**
* @param archived the archived to set
*/
public void setArchived(boolean archived) {
this.archived = archived;
}

/**
* @return the description
*/
public String getDescription() {
return description;
}

/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}

/**
* @return the id
*/
public String getId() {
return id;
}

/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}

/**
* @return the name
*/
public String getName() {
return name;
}

/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

/**
* @return the released
*/
public boolean isReleased() {
return released;
}

/**
* @param released the released to set
*/
public void setReleased(boolean released) {
this.released = released;
}
}
61 changes: 61 additions & 0 deletions src/test/java/info/bluefloyd/jenkins/FieldSummaryTest.java
@@ -0,0 +1,61 @@
package info.bluefloyd.jenkins;

import com.fasterxml.jackson.databind.ObjectMapper;
import info.bluefloyd.jira.model.IssueSummaryList;
import info.bluefloyd.jira.model.VersionSummary;
import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

/**
* Test case for Issue
*
* https://issues.jenkins-ci.org/browse/JENKINS-31755
*
* @author ian
*/
public class FieldSummaryTest {

/**
* JSON parsing fails when managed versions are used. Fixed by adding
* VersionSummary class to the model.
*
* @throws java.io.IOException
*/
@Test
public void TestFieldSummaryWithVersions() throws IOException {

String issueSummaryRESTResult = "{ \"expand\" : \"names,schema\",\n"
+ " \"issues\" : [ { \"expand\" : \"operations,versionedRepresentations,editmeta,changelog,transitions,renderedFields\",\n"
+ " \"fields\" : { \"summary\" : \"Check _52\",\n"
+ " \"versions\" : [ { \"archived\" : false,\n"
+ " \"description\" : \"Demo version\",\n"
+ " \"id\" : \"10505\",\n"
+ " \"name\" : \"1.0\",\n"
+ " \"released\" : false,\n"
+ " \"self\" : \"http://benjira01.tally.tallysolutions.com:8080/rest/api/2/version/10505\"\n"
+ " } ]\n"
+ " },\n"
+ " \"id\" : \"11274\",\n"
+ " \"key\" : \"SA-52\",\n"
+ " \"self\" : \"http://benjira01.tally.tallysolutions.com:8080/rest/api/2/issue/11274\"\n"
+ " } ],\n"
+ " \"maxResults\" : 1000,\n"
+ " \"startAt\" : 0,\n"
+ " \"total\" : 1\n"
+ "}";

ObjectMapper mapper = new ObjectMapper();
IssueSummaryList summaryList = mapper.readValue(issueSummaryRESTResult, IssueSummaryList.class);

assertNotNull(summaryList);
assertEquals(1,summaryList.getIssues().size());
assertEquals(1,summaryList.getIssues().get(0).getFields().getVersions().size());
VersionSummary version = summaryList.getIssues().get(0).getFields().getVersions().get(0);
assertFalse(version.isArchived());
assertFalse(version.isReleased());
assertEquals("10505",version.getId());
}
}