Code Monkey home page Code Monkey logo

jiratestresultreporter-plugin's Introduction

JiraTestResultReporter

Hello! Thank you for your interest in contributing to this plugin! If you were looking for the previous versions, please checkout the 1.x branch

How to submit a bug report/feature request

For submitting bug reports and feature requests please use the official JIRA for Jenkins and specify in the component field jiratestresultreporter-plugin .

In case of bug reports, please specify:

  • the plugin version
  • the Jenkins version
  • step by step instructions for how to reproduce the bug
  • the result as you see it
  • what do you think the expected result should be.

In case of feature requests please describe in detail what would you like this plugin to do and if possible specify your use case for it, so that make sure it is covered by an eventual implementation.

How to contribute

Contributions for this plugin should be in the form of pull requests.

Before you make a contribution, please make sure that there is a JIRA ticket for the bug that you are fixing, or for the feature that you are implementing as specified above. In some trivial cases, like clean up, refactoring, fixing typos there is no need for a JIRA issue.

One pull request should solve one JIRA ticket.

For your convinience you should try to use the following workflow:

Setup workflow

  • Fork on GitHub (click Fork button)
  • Clone to computer, use SSH URL ($ git clone [email protected]:${your_git_username}/JiraTestResultReporter-plugin.git)
  • cd into your repo: ($ cd JiraTestResultReporter-plugin/)
  • Set up remote upstream ($ git remote add upstream [email protected]:jenkinsci/JiraTestResultReporter-plugin.git)

Fixing a bug/Implementing a feature workflow

  • Create a branch for the JIRA issue that you are solving ($ git checkout -b issue/JENKINS-XXXXXX)
  • Develop on issue branch. [Time passes, the main repository accumulates new commits]
  • Commit changes to your local issue branch. ($ git add . ; git commit -m 'JENKINS-XXXXXX - commit message')
  • Fetch upstream ($ git fetch upstream)
  • Update local master ($ git checkout master; git merge upstream/master)
  • Rebase issue branch ($ git checkout issue/JENKINS-XXXXXX; git rebase master)
  • Repeat the above steps until dev is complete
  • Push branch to GitHub ($ git push)
  • Start your browser, go to your Github repo, switch to "JENKINS-XXXXXX" branch and press the [Pull Request] button.

Please keep the PRs as clean as possible by not mixing two or more issues into a single PR, or refactoring/clean up/typo fixing with solving issue. If you can have the feature implementation in a single git commit, that's even better. If you have splitted your work into many commits you can squash them into a single one afterwards, if it makes sense.

In any case, every commit should be fully functional. As specified in the workflow the branch name and each commit message shoud contain the issue key. We would love it if you could also provide tests for you issue in the PR (even if we don't have any, yet :) ).

WARNING: 2.x verions of this plugin are not compatible with the previous 1.x version. What this means is that your configurations related to this plugin will not be imported from previous versions when you do an upgrade.

What is does

This plugin allows you to create and/or link issues from Jira to failed tests in Jenkins. The creation/linking is done directly in the Jenkins interface. For the creation of the issues you can supply a template for what is going to be added in most of the issue's fields.

Global Configuration

Before doing anything else, the global configurations must be done. In order to do these go to Manage Jenkins -> Configure System -> JiraTestResultReporter and enter here the JIRA server url the username and password. It is highly recommended that you click the Validate Settings button every time you make any changes here. Also from here you can configure the global templates for Summary and Description, by clicking on the Advanced button. These templates will be used to create issues if they are not overridden in the job configuration.

Job Configuration

Pipeline Style Jobs

You can see below and example of a pipeline usage.

The thing to keep in mind is that you need to use the field keys and the values as they are defined in the REST API. For example, for the 'issueType', the API expects the ID for the issue type, in this case '1', instead of 'Bug'.

junit (
 testResults: '**/surefire-reports/*.xml',
 testDataPublishers: [
   jiraTestResultReporter(
     configs: [
       jiraStringField(fieldKey: 'summary', value: '${DEFAULT_SUMMARY}'),
       jiraStringField(fieldKey: 'description', value: '${DEFAULT_DESCRIPTION}'),
       jiraStringArrayField(fieldKey: 'labels', values: [jiraArrayEntry(value: 'Jenkins'), jiraArrayEntry(value:'Integration')])
     ],
     projectKey: 'J2J',
     issueType: '1',
     autoRaiseIssue: false,
     autoResolveIssue: false,
     autoUnlinkIssue: false,
     additionalAttachments: false,
   )
 ]
)

Classic Jobs

The first thing we need to do here is enabling the plugin:

  • Freestyle projects and Multi-configuration projects

    First, JUnit test reports need to be enabled by going to Add post-build action -> Publish JUnit test report. Then check the box next to JiraTestResultReporter in the Additional test report features section.

  • Maven Project

    Add post-build action -> Additional test report features -> check the box next to JiraTestResultReporter.

Configuration:

Insert the Project key in the respective field. Again, highly recommended to push the Validate Settings.

After setting the project key the Issue type select will be populated with the available issue types for that specific project.

If you check the Auto raise issue check box, this plugin will create and link issues for all the failing tests in new builds that don't already have linked issues.

In addition, if you check the Include additional junit-attachment attachments check box, this plugin will include as attachments of a Jira issue additional files from junit-attachments plugin. Only on raising new issues.

Checking Auto resolve issue check box will enable an experimental feature. Basically, if you had a test that was failing and you had a linked Jira issue to it, the plugin will try to resolve your issue. What this means is that it will look for available transitions from the current state and it will try to find one that in the name has the word "resolve". If such a transition is found it will apply it, otherwise it will just log a message. In future releases this will be configurable.

Only after configuring the fields above, if you want you can override the Summary and Description values by clicking the Advanced button. If you want, here you can configure all available fields for that specific issue type. Due to Jenkins interface development limitations, you have to search for the desired field from the four available types of fields, after clicking the Add Field Configuration.

Important: Do not leave empty values for fields, if you didn't find the desired field in the current chosen option, delete it before trying the next one.

Finally, I cannot say that this is recommended ( although it is (smile) ), read the help tag for the Validate Fields and if the warning there is not a problem for you click the button.

Usage

After building the project, go to the test results page. Next to the test cases you will see a blue plus button, next to a No issue message. If you want to create an issue, or link an existing one, click the blue plus button and choose the desired option. For unlinking an issue, click the red x button.

When creating, linking and unlinking issues, you it is recommended that wait for the page to reload, before doing something else for another test. Errors will be shown inline, if any.

Finally, your issues are created and you can see them by clicking the links directly from the Jenkins interface.

Variables

For text fields in the Job Configuration and Global Confinguration (Summary and Description only) you can use variables that will expand to the appropriate value when the issue is created in JIRA. You can use all the environment variables defined by Jenkins (see link). Additionaly, this plugin can expand a set of predefined variables that expose information about the test.

Implementation details

jiratestresultreporter-plugin's People

Contributors

andreituicu avatar basil avatar catalinluta avatar daniel-beck-bot avatar dependabot[bot] avatar imonteroperez avatar jglick avatar maplesteve avatar notmyfault avatar usmonster avatar zztalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jiratestresultreporter-plugin's Issues

Allow other JIRA projects when manually linking an issue

What feature do you want to see added?

When manually linking a JIRA issue i.e.
image

It would be IMHO better to ignore the current check i.e. verify that the entered project matches the project configured for the JiraTestResultReporter.
This way we could link tests to issues are opened for another project in our JIRA.
Currently this is not possible and results in a failure
image

If the entered issue ID does not exists in JIRA, then the response from JIRA would trigger the "Not a valid issue key" error

Upstream changes

No response

Check warnings

What feature do you want to see added?

There are multiple warnings visible within CI build, see e.g. https://ci.jenkins.io/job/Plugins/job/JiraTestResultReporter-plugin/job/master/51/console

16:36:43 [ERROR] Medium: org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor.templates is a mutable collection which should be package protected [org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor] At JiraTestDataPublisher.java:[line 367] MS_MUTABLE_COLLECTION_PKGPROTECT
16:36:43 [ERROR] Medium: Possible null pointer dereference of jiraPublisherJSON in org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor.validateFieldConfigs(String) [org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor, org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor, org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor] Dereferenced at JiraTestDataPublisher.java:[line 646]Null value at JiraTestDataPublisher.java:[line 636]Known null at JiraTestDataPublisher.java:[line 638] NP_NULL_ON_SOME_PATH
16:36:43 [ERROR] Medium: Redundant nullcheck of uri, which is known to be non-null in org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor.doValidateGlobal(String, String, String) [org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor] Redundant null check at JiraTestDataPublisher.java:[line 544] RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
16:36:43 [ERROR] Medium: org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor.validateFieldConfigs(String) makes inefficient use of keySet iterator instead of entrySet iterator [org.jenkinsci.plugins.JiraTestResultReporter.JiraTestDataPublisher$JiraTestDataPublisherDescriptor] At JiraTestDataPublisher.java:[line 640] WMI_WRONG_MAP_ITERATOR
16:36:43 [ERROR] High: Private readResolve method in org.jenkinsci.plugins.JiraTestResultReporter.JobConfigMapping$JobConfigEntry not inherited by subclasses. [org.jenkinsci.plugins.JiraTestResultReporter.JobConfigMapping$JobConfigEntry] At JobConfigMapping.java:[lines 118-119] SE_PRIVATE_READ_RESOLVE_NOT_INHERITED
16:36:43 [ERROR] Medium: Exception is caught when Exception is not thrown in org.jenkinsci.plugins.JiraTestResultReporter.TestToIssueMapping.saveMap(Job, HashMap) [org.jenkinsci.plugins.JiraTestResultReporter.TestToIssueMapping] At TestToIssueMapping.java:[line 77] REC_CATCH_EXCEPTION
16:36:43 [ERROR] Medium: Possible null pointer dereference in org.jenkinsci.plugins.JiraTestResultReporter.api.TestToIssueMappingApi.doJson(StaplerRequest, StaplerResponse) due to return value of called method [org.jenkinsci.plugins.JiraTestResultReporter.api.TestToIssueMappingApi, org.jenkinsci.plugins.JiraTestResultReporter.api.TestToIssueMappingApi] Dereferenced at TestToIssueMappingApi.java:[line 53]Known null at TestToIssueMappingApi.java:[line 50] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
16:36:43 [ERROR] High: Nullcheck of item at line 53 of value previously dereferenced in org.jenkinsci.plugins.JiraTestResultReporter.api.TestToIssueMappingApi.doJson(StaplerRequest, StaplerResponse) [org.jenkinsci.plugins.JiraTestResultReporter.api.TestToIssueMappingApi, org.jenkinsci.plugins.JiraTestResultReporter.api.TestToIssueMappingApi] At TestToIssueMappingApi.java:[line 53]Redundant null check at TestToIssueMappingApi.java:[line 55] RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE
16:36:43 [ERROR] Medium: org.jenkinsci.plugins.JiraTestResultReporter.config.SelectableArrayFields$SelectableArrayFieldsDescriptor.doFillValueItems(String, String, String) might ignore java.lang.Exception [org.jenkinsci.plugins.JiraTestResultReporter.config.SelectableArrayFields$SelectableArrayFieldsDescriptor, org.jenkinsci.plugins.JiraTestResultReporter.config.SelectableArrayFields$SelectableArrayFieldsDescriptor] At SelectableArrayFields.java:[line 164]At SelectableArrayFields.java:[line 164] DE_MIGHT_IGNORE
16:36:43 [ERROR] Medium: Exception is caught when Exception is not thrown in org.jenkinsci.plugins.JiraTestResultReporter.config.SelectableArrayFields$SelectableArrayFieldsDescriptor.doFillValueItems(String, String, String) [org.jenkinsci.plugins.JiraTestResultReporter.config.SelectableArrayFields$SelectableArrayFieldsDescriptor] At SelectableArrayFields.java:[line 164] REC_CATCH_EXCEPTION
16:36:43 [ERROR] Medium: org.jenkinsci.plugins.JiraTestResultReporter.config.UserFields is Serializable; consider declaring a serialVersionUID [org.jenkinsci.plugins.JiraTestResultReporter.config.UserFields] At UserFields.java:[lines 36-70] SE_NO_SERIALVERSIONID
16:36:43 [ERROR] Medium: org.jenkinsci.plugins.JiraTestResultReporter.restclientextensions.FullStatus defines equals but not hashCode [org.jenkinsci.plugins.JiraTestResultReporter.restclientextensions.FullStatus] At FullStatus.java:[lines 48-52] HE_EQUALS_NO_HASHCODE

at least they should be analysed and maybe fixed.

Upstream changes

No response

Are you interested in contributing this feature?

No response

Support PAT token

What feature do you want to see added?

PAT token support for Jira authentication as Bearer token, see https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html and there the section "Using PATs". I think it is not necessary to also support the creation of the PAT by the plugin that could be done by the user via Jira.

Don't mix that with Jira cloud service, see https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/ where the token could still be used instead of the password to basic auth.

On impl see:
https://community.atlassian.com/t5/Jira-questions/How-do-I-use-a-personal-access-token-PAT-in-jira-rest-java/qaq-p/1859167

There seems to exist a PR for the java client:
https://bitbucket.org/atlassian/jira-rest-java-client/pull-requests/125
which is not merged yet.

Upstream changes

No response

Are you interested in contributing this feature?

No response

Provide entry for jiraSelectableArrayField which have the name attribute instead of id - Add Version by name instead of id

What feature do you want to see added?

To set the field "version" on issue creation I only can reference a version by the internal version id. This is not very flexible.

The Jira API allows two kind of values. For the internal id it is {"id":999}. This is already usable with this syntax:

jiraSelectableArrayField(fieldKey: 'versions', values: [jiraArrayEntry(value:'999')])

To use the version name (like "v1.2.3") the API offers the format {"name":"v1.2.3"}.

I also want to reference my version by name. Maybe this could be somethink like this:

jiraSelectableArrayField(fieldKey: 'versions', values: [jiraArrayNameEntry(value:'v1.2.3')])

Or an more abstract version:

jiraSelectableArrayField(fieldKey: 'versions', values: [jiraAbstractEntry(attribute: 'name', value:'v1.2.3')])

This should apply for all selectable array field where jira uses an internal id like fixVersion.

Upstream changes

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.