/// <summary> /// Invoke Configure to setup the JIRA connection. This method must be invoked before creating issues via <see cref="IssueBuilder"/>. /// </summary> /// <param name="url">The URL of the JIRA SOAP service. E.g. https://your-jira-site.com</param> /// <param name="username">The username of the user to log into JIRA with.</param> /// <param name="password">The password of the user to log into JIRA with.</param> public static void Configure(string url, string username, string password) { _url = url; _username = username; _password = password; BrowseIssueUrl = url.EnsureTrailing("/") + "browse/"; _isConfigured = true; Service = new JiraSoapServiceService { Url = url.EnsureTrailing("/") + SoapServiceUrl }; Log.DebugFormat("JIRA was configured with url, username, password: '******', '{1}', '{2}'", _url, _username, _password.Mask()); }
protected override void Append(LoggingEvent loggingEvent) { var summary = Layout != null ? RenderLoggingEvent(loggingEvent) : loggingEvent.MessageObject.ToString(); var issue = new RemoteIssue { project = ProjectKey, type = IssueTypeId, summary = summary.Truncate(SummaryMaxCharCount) }; if (!string.IsNullOrEmpty(AssigneeUsername)) issue.assignee = AssigneeUsername; if (!string.IsNullOrEmpty(ComponentId)) issue.components = new[] { new RemoteComponent { id = ComponentId } }; var description = new StringBuilder(); if (summary.Length > SummaryMaxCharCount) description.AppendFormat("Message: {0}\n", summary); description.AppendFormat("Level: {0}\n", loggingEvent.Level); description.AppendFormat("Logger: {0}\n", loggingEvent.LoggerName); if (loggingEvent.ExceptionObject != null) { description.Append("\n{code:title=Exception}"); description.Append(loggingEvent.GetExceptionString()); description.Append("{code}"); } issue.description = description.ToString(); var service = new JiraSoapServiceService { Url = Url }; var token = service.login(Username, Password); LogLog.Debug(string.Format("Sending request to JIRA: {0}", issue.ToJson())); var returnedIssue = service.createIssue(token, issue); LogLog.Debug(string.Format("Got response from JIRA: {0}", returnedIssue.ToJson())); LogLog.Debug(string.Format("Created issue: {0}", returnedIssue.key)); }