Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira plugin doesn't update jira issues based on Commit messages #322

Open
abdelhafiz23 opened this issue Feb 24, 2021 · 2 comments
Open

Comments

@abdelhafiz23
Copy link

Hello,

i'm using the jira plugin version 3.2 on Jenkins 2.267.

And the plugin documentation isn't clear on how to make the jira plugin update automatically jira issues, during a jenkins build based on commit messages.

I configured the plugin as described in the documentation. I am able to get the Jira Issues and the jira release versions, with the Jira Release Version Parameter and the Jira Issue Parameter. So that means my Jira plugin configuration is ok.

I use the jiraComment step

          jiraComment([
            issueKey: 'TJJ-2',
            body: """
                  Git Changelog changelog

                  Changelog of Git Changelog.
                  """
          ])

and the JiraIssueUpdater

step([
            $class: 'JiraIssueUpdater',

to update Jira issues. It works fine, but they require the issue key to be explicitly mentionned.

But when i use for example:

          sh "git clone xxxxxx.git"
          sh 'cd xxxxx'
          sh 'cd xxxxxxx && git checkout test-jenkins-jira'
          sh 'cd xxxxxxx && git log -n 2'

The git log displays commit messages with jira keys in them

commit b5c2105ba9450107a843cc325c13582b3256442b
Date:   Wed Feb 17 17:52:25 2021 +0100

    TJJ-2 test comment

commit c2ea8664d57d8a3a690f3933fe286fc2f8cb12cb
Date:   Tue Feb 16 16:49:03 2021 +0100

    TJJ-1 update 1

The issue keys are TJJ-2 and TJJ-1 but those issues aren't updated automatically, no comments are created in them.

My questions are:

  • is the plugin supposed to update issues based on commit messages or branch names etc...?
  • If so how do i do that without using the jiraComment step, or JiraIssueUpdater, which don't read issue names from commit messages.

Thank you.

@rantoniuk
Copy link
Contributor

What you need is "Update relevant issues" action, but there is a known bug in it reported JENKINS-62706.

@abdelhafiz23
Copy link
Author

@warden Thank you for your answer.

In the plugin configuration i checked the Update Relevant Jira Issues For All Build Results checkbox.
And
I am using a pipeline with a stage containing the JiraIssueUpdater step which seems to be what you talking about:

    stage('Create release') {
      steps {
        script {
          deleteDir()
          sh "git clone [email protected]/spacekins.git"
          sh 'cd spacekins'
          sh 'cd spacekins && git checkout test-jenkins-jira'
          sh 'cd spacekins && git log -n 2'
        }
      }
    }
    stage('Test back pointer') {
      steps {
        script {
          step([
            $class: 'JiraIssueUpdater',
            issueSelector: [
              $class: 'DefaultIssueSelector'
            ],
            scm: [
              $class: 'GitSCM',
              userRemoteConfigs: [[
                url: '[email protected]:abdelhafiz23/FindET.git',
                name: 'origin',
                credentialsId: 'abdelpk'
                ]
              ],
              branches: [
                [ name: 'refs/heads/master', name: 'refs/heads/test-jenkins-jira', name: 'refs/heads/TJJ']
              ],
              browser: [
                $class: 'GithubWeb',
                repoUrl: 'https://github.com/abdelhafiz23/FindET.git'
              ],
              gitTool: '/usr/bin/git'
            ]
          ])

Before that step, i used the git log command to print some commits, with jira issue keys in them.

Does the plugin read the output of the git log ? Or does it scan the branches specified in the scm section of the step to update relevant issues? If so, i have no errors indicating the plugin wasn't able to use the informations i gave in the scm section of the stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants