Search in sources :

Example 1 with BUG_ISSUE_TYPE_ID

use of hudson.plugins.jira.JiraRestService.BUG_ISSUE_TYPE_ID in project jira-plugin by jenkinsci.

the class JiraCreateIssueNotifier method createJiraIssue.

/**
 * It creates a issue in the given project, with the given description, assignee,components and summary.
 * The created issue ID is saved to the file at "filename".
 *
 * @param build
 * @param filename
 * @return issue id
 * @throws IOException
 * @throws InterruptedException
 */
private Issue createJiraIssue(AbstractBuild<?, ?> build, String filename) throws IOException, InterruptedException {
    EnvVars vars = build.getEnvironment(TaskListener.NULL);
    JiraSession session = getJiraSession(build);
    String buildName = getBuildName(vars);
    String summary = String.format("Build %s failed", buildName);
    String description = String.format("%s\n\nThe build %s has failed.\nFirst failed run: %s", (this.testDescription.equals("")) ? "No description is provided" : vars.expand(this.testDescription), buildName, getBuildDetailsString(vars));
    Iterable<String> components = Arrays.stream(component.split(",")).filter(s -> !StringUtils.isEmpty(s)).map(s -> StringUtils.trim(s)).collect(Collectors.toList());
    Long type = typeId;
    if (type == null || type == 0) {
        // zero is default / invalid selection
        LOG.info("Returning default issue type id " + BUG_ISSUE_TYPE_ID);
        type = BUG_ISSUE_TYPE_ID;
    }
    Long priority = priorityId;
    if (priority != null && priority == 0) {
        // remove invalid priority selection
        priority = null;
    }
    Issue issue = session.createIssue(projectKey, description, assignee, components, summary, type, priority);
    writeInFile(filename, issue);
    return issue;
}
Also used : BUG_ISSUE_TYPE_ID(hudson.plugins.jira.JiraRestService.BUG_ISSUE_TYPE_ID) Priority(com.atlassian.jira.rest.client.api.domain.Priority) StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) Issue(com.atlassian.jira.rest.client.api.domain.Issue) DataBoundConstructor(org.kohsuke.stapler.DataBoundConstructor) AbstractBuild(hudson.model.AbstractBuild) BuildStepDescriptor(hudson.tasks.BuildStepDescriptor) BuildStepMonitor(hudson.tasks.BuildStepMonitor) QueryParameter(org.kohsuke.stapler.QueryParameter) StaplerRequest(org.kohsuke.stapler.StaplerRequest) IssueType(com.atlassian.jira.rest.client.api.domain.IssueType) Folder(com.cloudbees.hudson.plugins.folder.Folder) AncestorInPath(org.kohsuke.stapler.AncestorInPath) BuildListener(hudson.model.BuildListener) Item(hudson.model.Item) Extension(hudson.Extension) EnvVars(hudson.EnvVars) Path(java.nio.file.Path) Publisher(hudson.tasks.Publisher) Status(com.atlassian.jira.rest.client.api.domain.Status) TaskListener(hudson.model.TaskListener) ListBoxModel(hudson.util.ListBoxModel) Files(java.nio.file.Files) StatusCategory(com.atlassian.jira.rest.client.api.StatusCategory) FormValidation(hudson.util.FormValidation) BufferedWriter(java.io.BufferedWriter) Notifier(hudson.tasks.Notifier) Jenkins(jenkins.model.Jenkins) Launcher(hudson.Launcher) IOException(java.io.IOException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) ItemGroup(hudson.model.ItemGroup) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) Paths(java.nio.file.Paths) AbstractProject(hudson.model.AbstractProject) Result(hudson.model.Result) JSONObject(net.sf.json.JSONObject) BufferedReader(java.io.BufferedReader) EnvVars(hudson.EnvVars) Issue(com.atlassian.jira.rest.client.api.domain.Issue)

Aggregations

StatusCategory (com.atlassian.jira.rest.client.api.StatusCategory)1 Issue (com.atlassian.jira.rest.client.api.domain.Issue)1 IssueType (com.atlassian.jira.rest.client.api.domain.IssueType)1 Priority (com.atlassian.jira.rest.client.api.domain.Priority)1 Status (com.atlassian.jira.rest.client.api.domain.Status)1 Folder (com.cloudbees.hudson.plugins.folder.Folder)1 EnvVars (hudson.EnvVars)1 Extension (hudson.Extension)1 Launcher (hudson.Launcher)1 AbstractBuild (hudson.model.AbstractBuild)1 AbstractProject (hudson.model.AbstractProject)1 BuildListener (hudson.model.BuildListener)1 Item (hudson.model.Item)1 ItemGroup (hudson.model.ItemGroup)1 Result (hudson.model.Result)1 TaskListener (hudson.model.TaskListener)1 BUG_ISSUE_TYPE_ID (hudson.plugins.jira.JiraRestService.BUG_ISSUE_TYPE_ID)1 BuildStepDescriptor (hudson.tasks.BuildStepDescriptor)1 BuildStepMonitor (hudson.tasks.BuildStepMonitor)1 Notifier (hudson.tasks.Notifier)1