public static async Task <List <Issue> > GetIssueList(List <string> caseIdList) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "("; bool isFirstOne = true; foreach (string caseId in caseIdList) { if (isFirstOne) { sql += " \"SalesForce ID\" ~ " + caseId; isFirstOne = false; } else { sql += " OR \"SalesForce ID\" ~ " + caseId; } } sql += ")"; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetIssueListBySalesforceId(string salesforceId, List <string> projects) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "\"Salesforce ID\" ~ " + salesforceId; sql += " AND project in ( "; bool isFirstOne = true; foreach (string project in projects) { if (isFirstOne) { sql += project; isFirstOne = false; } else { sql += " , " + project; } } sql += ")"; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task<List<Issue>> GetIssueList(List<string> caseIdList) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "("; bool isFirstOne = true; foreach(string caseId in caseIdList) { if(isFirstOne) { sql += " \"SalesForce ID\" ~ " + caseId; isFirstOne = false; } else { sql += " OR \"SalesForce ID\" ~ " + caseId; } } sql += ")"; List<Issue> issueList = new List<Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return issueList; }
public static async Task <List <Issue> > GetCaseListFromCrossProjects(DateTime startDate, DateTime endDate, List <string> projects) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "resolutiondate >= " + String.Format("{0}-{1}-{2}", startDate.Year, startDate.Month, startDate.Day) + " AND " + " resolutiondate <= " + String.Format("{0}-{1}-{2}", endDate.Year, endDate.Month, endDate.Day); sql += " AND \"Salesforce ID\" !~ Empty "; sql += " AND project in ( "; bool isFirstOne = true; foreach (string project in projects) { if (isFirstOne) { sql += project; isFirstOne = false; } else { sql += " , " + project; } } sql += ")"; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <Issue> GetDatabaseTaskByCustomerID(string project, string type, string customer) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "("; if (customer.IndexOf(",") > 0) { sql += " created >= -15d AND summary ~ \"" + customer.Substring(0, customer.IndexOf(",")) + "\""; } else { sql += " created >= -15d AND summary ~ \"" + customer + "\""; } sql += ")"; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery(project, type, sql); foreach (Issue issue in issues) { if (issue != null) { return(issue); } } return(null); }
public static async Task<List<Issue>> GetIssueList(string email) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "assignee in (\"" + email + "\") and status in (\"Open\", \"In Progress\", \"Reopened\", \"Pending\", \"Development in Progress\") "; List<Issue> issueList = new List<Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return issueList; }
public static async Task<List<Issue>> GetIssueListByLabel(string label) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "labels = " + label + ""; List<Issue> issueList = new List<Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return issueList; }
public static async Task<List<Issue>> GetIssueListByStatus(string status) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "project = ENGSUPP AND status = \"" + status + "\" AND reporter in (\"[email protected]\")"; List<Issue> issueList = new List<Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return issueList; }
public static async Task <List <Issue> > GetIssueListByStatus(string status) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "project = ENGSUPP AND issuetype not in (subTaskIssueTypes()) AND status = \"" + status + "\" AND reporter in (\"[email protected]\")"; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetIssueListByLabel(string label) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "labels = " + label + ""; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetIssueList(string email) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "assignee in (\"" + email + "\") and status in (\"Open\", \"In Progress\", \"Reopened\", \"Pending\", \"Development in Progress\") "; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetUpdatedIssueListByTimeslot(DateTime from, DateTime to) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); //string sql = " updated >= " + from.ToString("yyyy-MM-dd") + " AND updated <= " + to.ToString("yyyy-MM-dd") + " AND assignee in (\"" + assignee + "\") "; string sql = " issuetype in (subTaskIssueTypes()) AND updated >= " + from.ToString("yyyy-MM-dd") + " AND updated <= " + to.ToString("yyyy-MM-dd") + " "; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetUpdatedIssueListByAssigneeList(DateTime from, DateTime to, List <string> assignees) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); //string sql = " updated >= " + from.ToString("yyyy-MM-dd") + " AND updated <= " + to.ToString("yyyy-MM-dd") + " "; string sql = ""; int fromTimeSlot = (int)DateTime.Now.Subtract(from).TotalHours; int toTimeSlot = (int)DateTime.Now.Subtract(to).TotalHours; if (toTimeSlot < 0) { sql = " updated >= -" + fromTimeSlot + "h "; } else { sql = " updated >= -" + fromTimeSlot + "h AND updated <= -" + toTimeSlot + "h "; } if (assignees.Count > 0) { sql += " AND assignee in ("; bool isFirst = true; foreach (var assignee in assignees) { if (isFirst) { sql += " \"" + assignee + "\" "; isFirst = false; } else { sql += " ,\"" + assignee + "\" "; } } sql += " )"; } List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetIssueListByCreatedDate(DateTime start, DateTime end) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); // http://www.cnblogs.com/polk6/p/5465088.html string sql = "issuetype not in (Task, Sub-task) AND reporter in (\"[email protected]\") AND created >= " + start.ToString("yyyy-MM-dd") + " AND created < " + end.ToString("yyyy-MM-dd") + " "; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetProductionIssueList() { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); // http://www.cnblogs.com/polk6/p/5465088.html string sql = " status in (Open, \"In Progress\", Reopened, Pending, \"Development in Progress\") AND not \"Salesforce ID\" is EMPTY AND reporter in (\"[email protected]\") "; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "Bug", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <List <Issue> > GetUpdatedIssueList(DateTime from, DateTime to) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = " issuetype not in (Task, Sub-task) AND reporter in (\"[email protected]\") "; sql += " AND resolutiondate >= " + from.ToString("yyyy-MM-dd") + " AND resolutiondate <= " + to.ToString("yyyy-MM-dd"); List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task <Issue> GetDatabaseTaskByCaseID(string project, string type, string caseid) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "("; sql += " \"summary\" ~ " + caseid; sql += ")"; List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery(project, type, sql); foreach (Issue issue in issues) { if (issue != null) { return(issue); } } return(null); }
// ReSharper disable PossibleMultipleEnumeration private void button1_Click(object sender, EventArgs e) { try { var jira = new JiraClient(JiraUrl, User, Password); var jiraIssues = jira.GetIssuesByQuery("USPL", "", Jql); var trello = new Trello(AppKey); trello.Authorize(UserToken); var trelloBoard = trello.Boards.ForMe().FirstOrDefault(b => b.Name == BoardName); var trelloLists = trello.Lists.ForBoard(trelloBoard); var trelloCards = trello.Cards.ForBoard(trelloBoard); var backlogList = trelloLists.FirstOrDefault(b => b.Name == BacklogName); foreach (var jiraIssue in jiraIssues) { var key = jiraIssue.key.ToLowerInvariant(); var cardTrello = trelloCards.FirstOrDefault(c => c.Name.ToLowerInvariant().Contains(key)); if (cardTrello == null) { Console.WriteLine(@"Creating {0}.", jiraIssue.key); var name = string.Format("({0}) {1} - {2}", jiraIssue.fields.issuetype.name, key.ToUpperInvariant(), jiraIssue.fields.summary); var defaultSprint = backlogList; if (!String.IsNullOrEmpty(jiraIssue.fields.status.name)) { name = string.Format("({0}) {1} - {2} [{3}]", jiraIssue.fields.issuetype.name, key.ToUpperInvariant(), jiraIssue.fields.summary, jiraIssue.fields.status.name); } foreach (var sprint in jiraIssue.fields.customfield_10007) { if (GetSprintState(sprint) == "CLOSED") { continue; } var sprintList = trelloLists.FirstOrDefault( l => l.Name.ToLowerInvariant().Equals(GetSprintName(sprint).ToLowerInvariant())); if (sprintList == null) { continue; } defaultSprint = sprintList; } var newCard = trello.Cards.Add(name, defaultSprint); if (checkBox1.Checked) { trello.Cards.AddLabel(newCard, Color.Red); } switch (jiraIssue.fields.issuetype.name.ToLowerInvariant()) { case "technical task": case "task": trello.Cards.AddLabel(newCard, Color.Blue); break; default: trello.Cards.AddLabel(newCard, Color.Sky); break; } switch (jiraIssue.fields.status.name.ToLowerInvariant()) { case "awaiting po acceptance": case "po signed off for production": case "in po acceptance": trello.Cards.AddLabel(newCard, Color.Yellow); trello.Cards.AddLabel(newCard, Color.Green); break; case "ready for development": case "in development": case "in qa": case "awaiting qa": trello.Cards.AddLabel(newCard, Color.Yellow); break; } trello.Cards.AddComment(newCard, "Imported from Jira"); } else { Console.WriteLine(@"Updating {0}.", jiraIssue.key); var updated = false; if (!String.IsNullOrEmpty(jiraIssue.fields.status.name)) { var name = string.Format("({0}) {1} - {2} [{3}]", jiraIssue.fields.issuetype.name, key.ToUpperInvariant(), jiraIssue.fields.summary, jiraIssue.fields.status.name); if (cardTrello.Name != name) { cardTrello.Name = name; updated = true; } } if (jiraIssue.fields.updated != null) { var lastActivity = jiraIssue.fields.updated.Value; if (cardTrello.DateLastActivity != lastActivity) { cardTrello.DateLastActivity = lastActivity; updated = true; } } var originalSprint = cardTrello.IdList; foreach ( var sprintList in jiraIssue.fields.customfield_10007 .Where(sprint => GetSprintState(sprint) != "CLOSED") // ReSharper disable once PossibleMultipleEnumeration .Select(sprint => trelloLists.FirstOrDefault(l => l.Name.ToLowerInvariant().Equals(GetSprintName(sprint).ToLowerInvariant()))) .Where(sprintList => sprintList != null && cardTrello.IdList != sprintList.Id)) { cardTrello.IdList = sprintList.Id; updated = true; } if (updated) { trello.Cards.Update(cardTrello); foreach (var label in cardTrello.Labels) { try { trello.Cards.AddLabel(cardTrello, label.Color); } catch (TrelloException ex) { if (ex.Message.Contains("that label is already on the card")) { continue; } throw; } } if (cardTrello.IdList != originalSprint) { try { if (!cardTrello.LabelColors.Contains(Color.Red)) { trello.Cards.AddLabel(cardTrello, Color.Red); } } catch (TrelloException ex) { if (!ex.Message.Contains("that label is already on the card")) { throw; } } } trello.Cards.AddComment(cardTrello, "Updated from Jira"); } switch (jiraIssue.fields.status.name.ToLowerInvariant()) { case "awaiting po acceptance": case "po signed off for production": case "in po acceptance": if (!cardTrello.LabelColors.Contains(Color.Yellow)) { trello.Cards.AddLabel(cardTrello, Color.Yellow); } if (!cardTrello.LabelColors.Contains(Color.Green)) { trello.Cards.AddLabel(cardTrello, Color.Green); } break; case "ready for development": case "in development": case "in qa": case "awaiting qa": if (!cardTrello.LabelColors.Contains(Color.Yellow)) { trello.Cards.AddLabel(cardTrello, Color.Yellow); } break; } } } var removedTrelloCards = trelloCards.Where(tc => tc.LabelColors.Contains(Color.Sky) && jiraIssues.Count(j => tc.Name.ToLowerInvariant().Contains(j.key.ToLowerInvariant())) == 0); foreach (var removedTrelloCard in removedTrelloCards) { if (removedTrelloCard.Labels.FirstOrDefault(t => t.Color == Color.Red) == null) { trello.Cards.AddLabel(removedTrelloCard, Color.Red); } trello.Cards.AddComment(removedTrelloCard, "Removed from Backlog in Jira"); } MessageBox.Show(@"RoadMap updated."); } catch (Exception ex) { MessageBox.Show(string.Format("Error. Message: {0}.", ex.Message)); } }
/// <summary> /// Обновить статусы у задач в жире /// </summary> /// <param name="branchName">название бранча</param> /// <param name="branchUrl">урл среды</param> /// <param name="failMessage">сообщение падения</param> /// <param name="url">урл тимсити</param> /// <param name="buildId">номер билда</param> public void UpdateJiraStatus(string branchName, string branchUrl, string failMessage, string url, string buildId) { //список задач ожидающихся в тест var issueListTest = _jiraClient.GetIssuesByQuery(_jiraInfo.ProjectKey, null, "status = \"" + _jiraInfo.TransitionTestName + "\" and resolution = Fixed and cf[11104] = \"" + branchName + "\"").ToList(); //список задач ожидающихся в релиз var issueListRelease = _jiraClient.GetIssuesByQuery(_jiraInfo.ProjectKey, null, "status = \"" + _jiraInfo.TransitionReleaseName + "\" and resolution = Fixed and cf[11104] = \"" + branchName + "\"").ToList(); if (failMessage == null) { //переводим в тест var tranTest = new Transition { id = _jiraInfo.TransitionTestId, fields = new { environment = branchUrl } }; foreach (var issue in issueListTest) { _jiraClient.TransitionIssue(issue, tranTest); Console.WriteLine("Задача " + issue.key + " переведена в тест"); } //переводим в релиз var tranRelease = new Transition { id = _jiraInfo.TransitionReleaseId, fields = new { environment = branchUrl } }; foreach (var issue in issueListRelease) { _jiraClient.TransitionIssue(issue, tranRelease); Console.WriteLine("Задача " + issue.key + " переведена в релиз"); } } //билд упал - переводим задачи Fixed в develop else { //переводим в develop var tranTest = new Transition { id = _jiraInfo.TransitionFailedTestId }; foreach (var issue in issueListTest) { _jiraClient.TransitionIssue(issue, tranTest); _jiraClient.CreateComment(issue, "Билд упал. Cообщение об ошибке: " + failMessage + Environment.NewLine + url + "/viewLog.html?buildId=" + buildId); Console.WriteLine("Задача " + issue.key + " переведена в develop"); } //переводим в develop var tranRelease = new Transition { id = _jiraInfo.TransitionFailedReleaseId }; //переводим в develop foreach (var issue in issueListRelease) { _jiraClient.TransitionIssue(issue, tranRelease); _jiraClient.CreateComment(issue, "Билд упал. Cообщение об ошибке: " + failMessage + Environment.NewLine + url + "/viewLog.html?buildId=" + buildId); Console.WriteLine("Задача " + issue.key + " переведена в Failed Build"); } } //список задач ожидающихся в тест в резолюции не fixed var issueListTestNotFixed = _jiraClient.GetIssuesByQuery(_jiraInfo.ProjectKey, null, "status = \"" + _jiraInfo.TransitionTestName + "\" and resolution != Fixed").ToList(); //список задач ожидающихся в релиз в резолюции не fixed var issueListReleaseNotFixed = _jiraClient.GetIssuesByQuery(_jiraInfo.ProjectKey, null, "status = \"" + _jiraInfo.TransitionReleaseName + "\" and resolution != Fixed").ToList(); //Задачи которые в резолюции не фиксед //по умолчанию переводим в тест и в релиз без указания урла //так как для них скорей всего не создавали бранча var tranTestNotFixed = new Transition { id = _jiraInfo.TransitionTestId, fields = new { environment = _jiraInfo.UrlByDefault } }; foreach (var issue in issueListTestNotFixed) { _jiraClient.TransitionIssue(issue, tranTestNotFixed); Console.WriteLine("Задача " + issue.key + " переведена в тест"); } var tranReleaseNotFixed = new Transition { id = _jiraInfo.TransitionReleaseId, fields = new { environment = _jiraInfo.UrlByDefault } }; foreach (var issue in issueListReleaseNotFixed) { _jiraClient.TransitionIssue(issue, tranReleaseNotFixed); Console.WriteLine("Задача " + issue.key + " переведена в релиз"); } //вывод Console.WriteLine( "Перевод задач для бранча " + branchName + " (" + branchUrl + ") :" + Environment.NewLine + issueListTest.Count + " задач было переведено " + (failMessage != null ? "в develop" : "в тест - Fixed") + Environment.NewLine + issueListTestNotFixed.Count + " задач было переведено в тест - не Fixed" + Environment.NewLine + issueListRelease.Count + " задач было переведено " + (failMessage != null ? "в develop" : "в релиз - Fixed") + Environment.NewLine + issueListReleaseNotFixed.Count + " задач было переведено в релиз - не Fixed"); }
public static async Task <List <Issue> > GetUpdatedIssueListByTimeslot(string userName, string password, DateTime from, DateTime to, List <string> subTaskStatusList = null, List <string> meoOptions = null) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", userName, password); int fromTimeSlot = (int)DateTime.Now.Subtract(from).TotalHours; int toTimeSlot = (int)DateTime.Now.Subtract(to).TotalHours; string sql = " issuetype in (subTaskIssueTypes()) "; if (userName != "*****@*****.**") { sql += " AND assignee = \"" + userName + "\" "; } if (toTimeSlot < 0) { sql += " AND updated >= -" + DateTime.Now.Subtract(from).Hours + "h "; } else { sql += " AND updated >= -" + fromTimeSlot + "h AND updated <= -" + toTimeSlot + "h "; } if (meoOptions == null || meoOptions.Count == 0) { sql += " AND \"Self Rating\" is EMPTY "; } else { sql += " AND \"Self Rating\" in ("; bool isFirstOne = true; foreach (string meo in meoOptions) { if (isFirstOne) { sql += meo; isFirstOne = false; } else { sql += "," + meo; } } sql += ") "; } if (subTaskStatusList == null || subTaskStatusList.Count == 0) { sql += " AND status in (Closed, Resolved) "; } else { sql += " AND status in ("; bool isFirstOne = true; foreach (string status in subTaskStatusList) { if (isFirstOne) { sql += "\"" + status + "\""; isFirstOne = false; } else { sql += "," + "\"" + status + "\""; } } sql += ") "; } List <Issue> issueList = new List <Issue>(); var issues = jira.GetIssuesByQuery("ENGSUPP", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return(issueList); }
public static async Task<List<Issue>> GetIssueListBySalesforceId(string salesforceId, List<string> projects) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "\"Salesforce ID\" ~ " + salesforceId; sql += " AND project in ( "; bool isFirstOne = true; foreach (string project in projects) { if (isFirstOne) { sql += project; isFirstOne = false; } else { sql += " , " + project; } } sql += ")"; List<Issue> issueList = new List<Issue>(); var issues = jira.GetIssuesByQuery("", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return issueList; }
public static async Task<List<Issue>> GetCaseListFromCrossProjects(DateTime startDate, DateTime endDate, List<string> projects) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); string sql = "resolutiondate >= " + String.Format("{0}-{1}-{2}", startDate.Year, startDate.Month, startDate.Day) + " AND " + " resolutiondate <= " + String.Format("{0}-{1}-{2}", endDate.Year, endDate.Month, endDate.Day); sql += " AND \"Salesforce ID\" !~ Empty "; sql += " AND project in ( "; bool isFirstOne = true; foreach (string project in projects) { if (isFirstOne) { sql += project; isFirstOne = false; } else { sql += " , " + project; } } sql += ")"; List<Issue> issueList = new List<Issue>(); var issues = jira.GetIssuesByQuery("", "", sql); foreach (Issue issue in issues) { issueList.Add(issue); } return issueList; }