public override void DeployRelease(JiraContext context) { var releaseNumber = context.FixForVersion; if (string.IsNullOrEmpty(releaseNumber)) { throw new ArgumentNullException("releaseNumber"); } if (string.IsNullOrEmpty(context.Project.Key)) { throw new InvalidOperationException("Application must be specified in category ID filter to close a release."); } // Ensure version exists. var versions = this.Service.getVersions(this.Token, context.Project.Key); var version = Array.Find(versions, v => releaseNumber.Equals((v.name ?? "").Trim(), StringComparison.OrdinalIgnoreCase)); if (version == null) { throw new InvalidOperationException("Version " + releaseNumber + " does not exist."); } // If version is already released, do nothing. if (version.released) { return; } // Otherwise release it. version.released = true; version.releaseDate = DateTime.Now; this.Service.releaseVersion(this.Token, context.Project.Key, version); }
public override IIssueTrackerIssue CreateIssue(JiraContext context, string title, string description, string type) { var versions = this.Service.getVersions(this.Token, context.Project.Key) .Where(v => string.Equals(v.name, context.FixForVersion, StringComparison.OrdinalIgnoreCase)) .ToArray(); if (context.FixForVersion != null && versions.Length == 0) { this.log.LogWarning($"Could not set Fix For version to '{context.FixForVersion}' because it was not found in JIRA for project key '{context.Project.Key}'."); } var issue = this.Service.createIssue( this.Token, new RemoteIssue { project = context.Project.Key, summary = title, description = description, type = type, fixVersions = versions } ); return(new JiraIssue(issue, this.IssueStatuses, this.serverUrl)); }
public override void CreateRelease(JiraContext context) { var releaseNumber = context.FixForVersion; if (string.IsNullOrEmpty(releaseNumber)) { throw new ArgumentNullException("releaseNumber"); } if (string.IsNullOrEmpty(context.Project.Key)) { throw new InvalidOperationException("Application must be specified in category ID filter to create a release."); } // If version is already created, do nothing. var versions = this.Service.getVersions(this.Token, context.Project.Key); if (Array.Find(versions, v => releaseNumber.Equals((v.name ?? "").Trim(), StringComparison.OrdinalIgnoreCase)) != null) { return; } // Otherwise add it. this.Service.addVersion(this.Token, context.Project.Key, new RemoteVersion { name = releaseNumber }); }
public override IEnumerable <IIssueTrackerIssue> EnumerateIssues(JiraContext context) { var version = this.Service.getVersions(this.Token, context.Project.Key) .FirstOrDefault(v => string.Equals(v.name, context.FixForVersion, StringComparison.OrdinalIgnoreCase)); if (version == null) { return(Enumerable.Empty <IIssueTrackerIssue>()); } var projectFilter = string.Empty; if (!string.IsNullOrEmpty(context.Project.Key)) { projectFilter = " and project = \"" + context.Project.Key + "\""; } var issues = this.Service.getIssuesFromJqlSearch( this.Token, string.Format("fixVersion = \"{0}\" {1}", context.FixForVersion, projectFilter), int.MaxValue ); if (issues.Length == 0) { return(Enumerable.Empty <IIssueTrackerIssue>()); } var baseUrl = this.serverUrl.TrimEnd('/'); return(from i in issues select new JiraIssue(i, this.IssueStatuses, baseUrl)); }
public override void AddComment(JiraContext context, string issueId, string commentText) { var comment = new RemoteComment { body = commentText }; this.Service.addComment(this.Token, issueId, comment); }
public override void CreateRelease(JiraContext context) { var version = this.TryGetVersion(context); if (version != null) { return; } this.restClient.CreateVersion(context.Project.Key, context.FixForVersion); }
public override IEnumerable <IIssueTrackerIssue> EnumerateIssues(JiraContext context) { var version = this.TryGetVersion(context); if (version == null) { return(Enumerable.Empty <IIssueTrackerIssue>()); } return(this.restClient.GetIssues(context.Project.Key, version.Name)); }
public void CloseAllIssues(JiraContext context) { foreach (var issue in this.EnumerateIssues(context)) { if (issue.IsClosed) { this.log.LogDebug($"{issue.Id} is already closed, skipping..."); continue; } this.CloseIssue(context, issue.Id); } }
private ProjectVersion TryGetVersion(JiraContext context) { if (string.IsNullOrEmpty(context.FixForVersion)) { throw new ArgumentException(nameof(context.FixForVersion)); } if (string.IsNullOrEmpty(context.Project.Key)) { throw new InvalidOperationException("Application must be specified in category ID filter to create a release."); } return(this.restClient.GetVersions(context.Project.Key).FirstOrDefault(v => v.Name == context.FixForVersion)); }
public override void CloseIssue(JiraContext context, string issueId) { var availableActions = this.Service.getAvailableActions(this.Token, issueId); var closeAction = availableActions .FirstOrDefault(a => string.Equals(a.name, "Close Issue", StringComparison.OrdinalIgnoreCase)); this.Service.progressWorkflowAction( this.Token, issueId, closeAction.id, new RemoteFieldValue[0] ); }
public override IEnumerable <Transition> GetTransitions(JiraContext context) { var issue = this.EnumerateIssues(context).LastOrDefault(); if (issue == null) { return(Enumerable.Empty <Transition>()); } var transitions = this.restClient.GetTransitions(issue.Id); return(transitions); }
public override void CloseIssue(JiraContext context, string issueId) { var validTransitions = this.restClient.GetTransitions(issueId); var closeTransition = validTransitions.FirstOrDefault(t => t.Name.Equals(context.ClosedState, StringComparison.OrdinalIgnoreCase)); if (closeTransition == null) { this.log.LogError($"Cannot close issue {issueId} because the issue cannot be transitioned to the configured closed state on the provider: {context.ClosedState}"); } else { this.restClient.TransitionIssue(issueId, closeTransition.Id); } }
public override void DeployRelease(JiraContext context) { var version = this.TryGetVersion(context); if (version == null) { throw new InvalidOperationException("Version " + context.FixForVersion + " does not exist."); } if (version.Released) { return; } this.restClient.ReleaseVersion(context.Project.Key, version.Id); }
public override void TransitionIssue(JiraContext context, string issueId, string issueStatus) { if (string.IsNullOrWhiteSpace(issueStatus)) { throw new ArgumentException("The status being applied must contain text.", nameof(issueStatus)); } var issue = this.restClient.GetIssue(issueId); if (issue.Status == issueStatus) { this.log.LogDebug($"{issue.Id} is already in the {issueStatus} status."); return; } this.ChangeIssueStatusInternal(issue, issueStatus); }
public override void TransitionIssuesInStatus(JiraContext context, string fromStatus, string toStatus) { if (string.IsNullOrWhiteSpace(toStatus)) { throw new ArgumentException("The status being applied must contain text.", nameof(toStatus)); } foreach (var issue in this.EnumerateIssues(context)) { if (!string.IsNullOrEmpty(fromStatus) && !string.Equals(issue.Status, fromStatus, StringComparison.OrdinalIgnoreCase)) { this.log.LogDebug($"{issue.Id} ({issue.Status}) is not in the {fromStatus} status, and will not be changed."); continue; } this.ChangeIssueStatusInternal(issue, toStatus); } }
public override void TransitionIssuesInStatus(JiraContext context, string fromStatus, string toStatus) { // verify status name is text toStatus = (toStatus ?? "").Trim(); if (string.IsNullOrEmpty(toStatus) || toStatus.Length < 2) { throw new ArgumentException("The status being applied must contain text and be at least 2 characters long", "newStatus"); } foreach (var jiraIssue in this.EnumerateIssues(context)) { if (!string.IsNullOrEmpty(fromStatus) && !string.Equals(jiraIssue.Status, fromStatus, StringComparison.OrdinalIgnoreCase)) { this.log.LogDebug($"{jiraIssue.Id} ({jiraIssue.Status}) is not in the {fromStatus} status, and will not be changed."); continue; } this.ChangeIssueStatusInternal((JiraIssue)jiraIssue, toStatus); } }
public override void TransitionIssue(JiraContext context, string issueId, string issueStatus) { // verify status name is text issueStatus = (issueStatus ?? "").Trim(); if (string.IsNullOrEmpty(issueStatus) || issueStatus.Length < 2) { throw new ArgumentException("The status being applied must contain text and be at least 2 characters long", "newStatus"); } // return if the issue is already set to the new status var issue = this.Service.getIssue(this.Token, issueId); var jiraIssue = new JiraIssue(issue, this.IssueStatuses, this.serverUrl); if (jiraIssue.Status == issueStatus) { this.log.LogDebug($"{jiraIssue.Id} is already in the {issueStatus} status."); return; } this.ChangeIssueStatusInternal(jiraIssue, issueStatus); }
public override Task <IEnumerable <IIssueTrackerIssue> > EnumerateIssuesAsync(JiraContext context) { return(this.restClient.GetIssuesAsync(context.GetJql())); }
public abstract void TransitionIssue(JiraContext context, string issueId, string issueStatus);
public abstract IIssueTrackerIssue CreateIssue(JiraContext context, string title, string description, string type);
public abstract void CloseIssue(JiraContext context, string issueId);
public abstract void CreateRelease(JiraContext context);
public override IIssueTrackerIssue CreateIssue(JiraContext context, string title, string description, string type) { return(this.restClient.CreateIssue(context.Project.Key, title, description, type, context.FixForVersion)); }
public abstract void AddComment(JiraContext context, string issueId, string commentText);
public override void AddComment(JiraContext context, string issueId, string commentText) { this.restClient.AddComment(issueId, commentText); }
public abstract void TransitionIssuesInStatus(JiraContext context, string fromStatus, string toStatus);
public override IEnumerable <Transition> GetTransitions(JiraContext context) { return(Enumerable.Empty <Transition>()); }
public abstract void DeployRelease(JiraContext context);
public override Task <IEnumerable <IIssueTrackerIssue> > EnumerateIssuesAsync(JiraContext context) { var issues = this.EnumerateIssues(context); return(Task.FromResult(issues)); }
public abstract Task <IEnumerable <IIssueTrackerIssue> > EnumerateIssuesAsync(JiraContext context);