#56 - Add support to archive (retire) release versions.
Added support for Jira. There's no such concept for GitHub.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2016 the original author or authors.
|
* Copyright 2014-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,7 +26,7 @@ import org.springframework.plugin.core.Plugin;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for issue tracker operations.
|
* Interface for issue tracker operations.
|
||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +56,7 @@ public interface IssueTracker extends Plugin<Project> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Ticket} that tracks modifications in the context of a release.
|
* Returns the {@link Ticket} that tracks modifications in the context of a release.
|
||||||
*
|
*
|
||||||
* @param module the module to lookup the {@link Ticket} for, must not be {@literal null}.
|
* @param module the module to lookup the {@link Ticket} for, must not be {@literal null}.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -74,16 +74,23 @@ public interface IssueTracker extends Plugin<Project> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a release version if release version is missing.
|
* Creates a release version if release version is missing.
|
||||||
*
|
*
|
||||||
* @param module must not be {@literal null}.
|
* @param module must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
void createReleaseVersion(ModuleIteration module);
|
void createReleaseVersion(ModuleIteration module);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retire the release version from the active versions for a {@link ModuleIteration}.
|
||||||
|
*
|
||||||
|
* @param module must not be {@literal null}.
|
||||||
|
*/
|
||||||
|
void archiveReleaseVersion(ModuleIteration module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create release ticket if release ticket is missing.
|
* Create release ticket if release ticket is missing.
|
||||||
* <p>
|
* <p>
|
||||||
* TODO: Return created ticket
|
* TODO: Return created ticket
|
||||||
*
|
*
|
||||||
* @param module must not be {@literal null}.
|
* @param module must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
void createReleaseTicket(ModuleIteration module);
|
void createReleaseTicket(ModuleIteration module);
|
||||||
@@ -98,7 +105,7 @@ public interface IssueTracker extends Plugin<Project> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns the release ticket for the given {@link ModuleIteration} to the current user.
|
* Assigns the release ticket for the given {@link ModuleIteration} to the current user.
|
||||||
*
|
*
|
||||||
* @param module must not be {@literal null}.
|
* @param module must not be {@literal null}.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -106,7 +113,7 @@ public interface IssueTracker extends Plugin<Project> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Changelog} for the given {@link ModuleIteration}.
|
* Returns the {@link Changelog} for the given {@link ModuleIteration}.
|
||||||
*
|
*
|
||||||
* @param module must not be {@literal null}.
|
* @param module must not be {@literal null}.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +121,7 @@ public interface IssueTracker extends Plugin<Project> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the given {@link ModuleIteration}.
|
* Closes the given {@link ModuleIteration}.
|
||||||
*
|
*
|
||||||
* @param module must not be {@literal null}.
|
* @param module must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
void closeIteration(ModuleIteration module);
|
void closeIteration(ModuleIteration module);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2016 the original author or authors.
|
* Copyright 2014-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -110,6 +110,11 @@ class IssueTrackerCommands extends TimedCommand {
|
|||||||
iteration.forEach(module -> getTrackerFor(module).closeIteration(module));
|
iteration.forEach(module -> getTrackerFor(module).closeIteration(module));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CliCommand("tracker archive")
|
||||||
|
public void archiveIteration(@CliOption(key = "", mandatory = true) TrainIteration iteration) {
|
||||||
|
iteration.forEach(module -> getTrackerFor(module).archiveReleaseVersion(module));
|
||||||
|
}
|
||||||
|
|
||||||
private Changelog getChangelog(ModuleIteration module) {
|
private Changelog getChangelog(ModuleIteration module) {
|
||||||
return getTrackerFor(module).getChangelogFor(module);
|
return getTrackerFor(module).getChangelogFor(module);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,6 +222,15 @@ class GitHub implements IssueTracker {
|
|||||||
new HttpEntity<Object>(githubMilestone.toMilestone(), httpHeaders), GitHubIssue.Milestone.class, parameters);
|
new HttpEntity<Object>(githubMilestone.toMilestone(), httpHeaders), GitHubIssue.Milestone.class, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.release.tracker.IssueTracker#retireReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void archiveReleaseVersion(ModuleIteration module) {
|
||||||
|
logger.log(module, "Skipping milestone archival");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class Jira implements JiraConnector {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.release.jira.JiraConnector#createReleaseVersion(org.springframework.data.release.model.ModuleIteration, org.springframework.data.release.jira.Credentials)
|
* @see org.springframework.data.release.jira.JiraConnector#createReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createReleaseVersion(ModuleIteration moduleIteration) {
|
public void createReleaseVersion(ModuleIteration moduleIteration) {
|
||||||
@@ -236,8 +236,34 @@ class Jira implements JiraConnector {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.release.jira.JiraConnector#findJiraReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
* @see org.springframework.data.release.jira.JiraConnector#retireReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
|
public void archiveReleaseVersion(ModuleIteration module) {
|
||||||
|
|
||||||
|
Assert.notNull(module, "ModuleIteration must not be null.");
|
||||||
|
|
||||||
|
HttpHeaders httpHeaders = newUserScopedHttpHeaders();
|
||||||
|
|
||||||
|
findJiraReleaseVersion(module) //
|
||||||
|
.filter(JiraReleaseVersion::isActive) //
|
||||||
|
.map(JiraReleaseVersion::markArchived) //
|
||||||
|
.ifPresent(version -> {
|
||||||
|
|
||||||
|
logger.log(module, "Marking version %s as archived.", version);
|
||||||
|
|
||||||
|
Map<String, Object> parameters = newUrlTemplateVariables();
|
||||||
|
parameters.put("id", version.getId());
|
||||||
|
|
||||||
|
operations.exchange(VERSION_TEMPLATE, HttpMethod.PUT, new HttpEntity<Object>(version, httpHeaders), Map.class,
|
||||||
|
parameters);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.release.jira.JiraConnector#findJiraReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
||||||
|
*/
|
||||||
@Cacheable("release-version")
|
@Cacheable("release-version")
|
||||||
public Optional<JiraReleaseVersion> findJiraReleaseVersion(ModuleIteration moduleIteration) {
|
public Optional<JiraReleaseVersion> findJiraReleaseVersion(ModuleIteration moduleIteration) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,16 @@
|
|||||||
|
|
||||||
package org.springframework.data.release.issues.jira;
|
package org.springframework.data.release.issues.jira;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import org.springframework.data.release.model.ModuleIteration;
|
import org.springframework.data.release.model.ModuleIteration;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value object to bind REST responses to.
|
* Value object to bind REST responses to.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@Value
|
@Value
|
||||||
@@ -32,6 +33,7 @@ class JiraReleaseVersion {
|
|||||||
|
|
||||||
String id, name, project, description;
|
String id, name, project, description;
|
||||||
boolean released;
|
boolean released;
|
||||||
|
boolean archived;
|
||||||
|
|
||||||
public static JiraReleaseVersion of(ModuleIteration moduleIteration, JiraVersion jiraVersion) {
|
public static JiraReleaseVersion of(ModuleIteration moduleIteration, JiraVersion jiraVersion) {
|
||||||
|
|
||||||
@@ -39,11 +41,15 @@ class JiraReleaseVersion {
|
|||||||
Assert.notNull(jiraVersion, "JiraVersion must not be null.");
|
Assert.notNull(jiraVersion, "JiraVersion must not be null.");
|
||||||
|
|
||||||
return new JiraReleaseVersion(null, jiraVersion.toString(), moduleIteration.getProjectKey().getKey(),
|
return new JiraReleaseVersion(null, jiraVersion.toString(), moduleIteration.getProjectKey().getKey(),
|
||||||
jiraVersion.getDescription(), false);
|
jiraVersion.getDescription(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JiraReleaseVersion markReleased() {
|
public JiraReleaseVersion markReleased() {
|
||||||
return new JiraReleaseVersion(id, name, project, description, true);
|
return new JiraReleaseVersion(id, name, project, description, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JiraReleaseVersion markArchived() {
|
||||||
|
return new JiraReleaseVersion(id, name, project, description, released, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSameNameAs(JiraVersion jiraVersion) {
|
public boolean hasSameNameAs(JiraVersion jiraVersion) {
|
||||||
@@ -54,4 +60,9 @@ class JiraReleaseVersion {
|
|||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return !released;
|
return !released;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isActive() {
|
||||||
|
return !archived;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
|
|||||||
|
|
||||||
static final String CREATE_ISSUE_URI = "/rest/api/2/issue";
|
static final String CREATE_ISSUE_URI = "/rest/api/2/issue";
|
||||||
static final String CREATE_VERSION_URI = "/rest/api/2/version";
|
static final String CREATE_VERSION_URI = "/rest/api/2/version";
|
||||||
|
static final String UPDATE_VERSION_URI = "/rest/api/2/version/15475";
|
||||||
static final String SEARCH_URI = "/rest/api/2/search";
|
static final String SEARCH_URI = "/rest/api/2/search";
|
||||||
static final String PROJECT_VERSION_URI = "/rest/api/2/project/%s/version";
|
static final String PROJECT_VERSION_URI = "/rest/api/2/project/%s/version";
|
||||||
static final String PROJECT_COMPONENTS_URI = "/rest/api/2/project/%s/components";
|
static final String PROJECT_COMPONENTS_URI = "/rest/api/2/project/%s/components";
|
||||||
@@ -167,7 +168,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
|
|||||||
jira.createReleaseVersion(REST_HOPPER_RC1);
|
jira.createReleaseVersion(REST_HOPPER_RC1);
|
||||||
|
|
||||||
verify(postRequestedFor(urlPathMatching(CREATE_VERSION_URI)).withRequestBody(equalToJson(
|
verify(postRequestedFor(urlPathMatching(CREATE_VERSION_URI)).withRequestBody(equalToJson(
|
||||||
"{\"name\":\"2.5 RC1 (Hopper)\",\"project\":\"DATAREST\",\"description\":\"Hopper RC1\", \"released\":false}")));
|
"{\"name\":\"2.5 RC1 (Hopper)\",\"project\":\"DATAREST\",\"description\":\"Hopper RC1\", \"released\":false, \"archived\":false}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,6 +186,25 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
|
|||||||
verify(0, postRequestedFor(urlPathMatching(CREATE_VERSION_URI)));
|
verify(0, postRequestedFor(urlPathMatching(CREATE_VERSION_URI)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #56
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void archiveReleaseVersionShouldArchiveReleaseVersion() throws Exception {
|
||||||
|
|
||||||
|
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST");
|
||||||
|
|
||||||
|
mockGetProjectVersionsWith("releaseVersions.json", moduleIteration.getProjectKey());
|
||||||
|
mockService.stubFor(put(urlPathMatching(UPDATE_VERSION_URI)).//
|
||||||
|
willReturn(json("versionCreated.json")));
|
||||||
|
|
||||||
|
jira.archiveReleaseVersion(moduleIteration);
|
||||||
|
|
||||||
|
verify(putRequestedFor(urlPathMatching(UPDATE_VERSION_URI))
|
||||||
|
.withRequestBody(equalToJson("{\"id\":\"15475\",\"name\":\"2.5 RC1 (Hopper)\","
|
||||||
|
+ "\"description\":\"Hopper RC1\", \"released\":true,\"archived\":true}")));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #5
|
* @see #5
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user