use of com.atlassian.jira.rest.client.api.domain.Version in project jira-plugin by jenkinsci.
the class JiraReplaceFixVersionByRegExTest method getIssue.
private Issue getIssue(String fixVersion, long id) throws URISyntaxException {
List<Version> fixVersions = new ArrayList<Version>();
fixVersions.add(new Version(new URI("self"), 0L, fixVersion, null, false, false, null));
return new Issue("", new URI(""), PROJECT_KEY + id, id, null, null, null, null, null, null, null, null, null, null, null, null, null, fixVersions, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
}
use of com.atlassian.jira.rest.client.api.domain.Version in project jira-plugin by jenkinsci.
the class JiraSession method migrateIssuesToFixVersion.
/**
* Replaces the fix version list of all issues matching the JQL Query with the version specified.
*
* @param projectKey The Jira Project key
* @param version The replacement version
* @param query The JQL Query
*/
public void migrateIssuesToFixVersion(String projectKey, String version, String query) throws TimeoutException {
Version newVersion = getVersionByName(projectKey, version);
if (newVersion == null) {
LOGGER.warning("Version " + version + " was not found");
return;
}
LOGGER.fine("Fetching versions with JQL:" + query);
List<Issue> issues = service.getIssuesFromJqlSearch(query, Integer.MAX_VALUE);
if (issues == null || issues.isEmpty()) {
return;
}
LOGGER.fine("Found issues: " + issues.size());
issues.stream().forEach(issue -> {
LOGGER.fine("Migrating issue: " + issue.getKey());
service.updateIssue(issue.getKey(), Collections.singletonList(newVersion));
});
}
use of com.atlassian.jira.rest.client.api.domain.Version in project jira-plugin by jenkinsci.
the class JiraVersionParameterDefinition method getVersions.
public List<JiraVersionParameterDefinition.Result> getVersions() throws IOException {
Job<?, ?> contextJob = Stapler.getCurrentRequest().findAncestorObject(Job.class);
JiraSite site = JiraSite.get(contextJob);
if (site == null)
throw new IllegalStateException("Jira site needs to be configured in the project " + contextJob.getFullDisplayName());
JiraSession session = site.getSession(contextJob);
if (session == null)
throw new IllegalStateException("Remote access for Jira isn't configured in Jenkins");
return session.getVersions(projectKey).stream().sorted(VersionComparator.INSTANCE).filter(version -> match(version)).map(version -> new Result(version)).collect(Collectors.toList());
}
use of com.atlassian.jira.rest.client.api.domain.Version in project opennms by OpenNMS.
the class ListVersionsCommand method doExecute.
@Override
protected void doExecute(JiraRestClient jiraRestClient) throws Exception {
final String theProjectKey = Strings.isNullOrEmpty(projectKey) ? getConfig().getProjectKey() : projectKey;
final Iterable<Version> versions = jiraRestClient.getProjectClient().getProject(theProjectKey).get().getVersions();
if (!versions.iterator().hasNext()) {
System.out.println("No versions found for project '" + theProjectKey + "'.");
return;
}
System.out.println(String.format(DEFAULT_ROW_FORMAT, "Id", "Name", "Description"));
for (Version eachVersion : versions) {
System.out.println(String.format(DEFAULT_ROW_FORMAT, eachVersion.getId(), eachVersion.getName(), eachVersion.getDescription() == null ? "" : removeNewLines(eachVersion.getDescription())));
}
}
use of com.atlassian.jira.rest.client.api.domain.Version in project staf by simpleworks-gmbh.
the class TestFloFixVersion method addFixVersions.
public void addFixVersions(final List<FixVersion> fetchedFixedVersion, final String id) {
if (Convert.isEmpty(fetchedFixedVersion)) {
throw new IllegalArgumentException("fetchedFixedVersion can't be null or empty string.");
}
if (Convert.isEmpty(id)) {
throw new IllegalArgumentException("id can't be null or empty string.");
}
try {
final Promise<Issue> promise = jira.getIssue(id);
final Issue issue = promise.claim();
if (issue == null) {
throw new RuntimeException("issue can't be null.");
}
final IssueInputBuilder issueBuilder = new IssueInputBuilder();
List<Version> versions = new ArrayList<Version>();
for (final FixVersion fixVersion : fetchedFixedVersion) {
if (!versions.add(new Version(new URI(fixVersion.getSelf()), null, fixVersion.getName(), fixVersion.getDescription(), false, false, null))) {
TestFloFixVersion.logger.error(String.format("can't add version '%s'.", fixVersion.getId()));
}
}
issueBuilder.setFixVersions(versions);
final IssueInput newIssue = issueBuilder.build();
if (newIssue == null) {
throw new IllegalArgumentException("newIssue can't be null or empty string.");
}
final Promise<Void> update = jira.updateIssue(id, newIssue);
update.claim();
} catch (Exception ex) {
if (TestFloFixVersion.logger.isDebugEnabled()) {
TestFloFixVersion.logger.debug(String.format("can't add fix version '%s' for testcase '%s'.", String.join(", ", fetchedFixedVersion.stream().map(v -> v.toString()).collect(Collectors.toList())), id), ex);
}
}
}
Aggregations