[JIRA] (JENKINS-49627) Last Changes Plugin shows git changes only in the first directory of the multidirectory pipeline

2 views
Skip to first unread message

anastasiia.vlaskina@gmail.com (JIRA)

unread,
Feb 19, 2018, 9:47:02 AM2/19/18
to jenkinsc...@googlegroups.com
Anastasiia Vlaskina created an issue
 
Jenkins / Bug JENKINS-49627
Last Changes Plugin shows git changes only in the first directory of the multidirectory pipeline
Issue Type: Bug Bug
Assignee: Rafael Pestano
Attachments: Screenshot from 2018-02-19 15-44-34.png
Components: last-changes-plugin
Created: 2018-02-19 14:46
Environment: Jenkins 2.101
Last Changes Plugin 2.6
Priority: Major Major
Reporter: Anastasiia Vlaskina

I'd like to see git changes in all 3 projects PIPELINE_PROJECT, FOO_PROJECT and BAR_PROJECT under the link workspace/<build_number>/last-changes/.

However, I see only the change in the first repo PIPELINE_PROJECT. Nevertheless, the links themselves contain right info about commits in all 3 repos. As you can see, all commit ids are different.

// Last changes from revision f566cf1 to d1e91ab published successfully!

Last changes from revision 5d837fd to 4ea9b64 published successfully!

Last changes from revision 1e840f9 to e53ecf8 published successfully!

This is my Jenkinsfile

 

 

//node(JENKINS_NODE) {
  try {
    stage('Checkout repos') {
      echo '\n========== Checking out required repositories  ==========\n'
      DEPENDENCY_REPOS = [
        [
          project:           PIPELINE_PROJECT,
          branch:            PIPELINE_BRANCH,
          relativeTargetDir: '.',
        ],
        [
          project:           FOO_PROJECT,
          branch:            FOO_BRANCH,
          relativeTargetDir: 'sync_folders/foo_project',
        ],
        [
          project:           BAR_PROJECT,
          branch:            BAR_BRANCH,
          relativeTargetDir: 'sync_folders/bar_project',
        ],
      ]

      GERRIT_URL    = 'gerrit_url'
      GITLAB_URL    = 'gitlab_url'
      CREDENTIALSID = 'id'

      for ( repo in DEPENDENCY_REPOS ) {
        repo_name = repo['project'].tokenize('/')[-1]
        repo_settings = [
          $class: 'GitSCM',
          branches: null,
          doGenerateSubmoduleConfigurations: false,
          extensions: [
              [
                  $class: 'RelativeTargetDirectory',
                  relativeTargetDir: repo['relativeTargetDir']
              ],
              [$class: 'WipeWorkspace']
          ],
          submoduleCfg: [],
          userRemoteConfigs: [
            [
              credentialsId: CREDENTIALSID
            ]
          ]
        ]
        if (params.GERRIT_CHANGE_ID && GERRIT_PROJECT.tokenize('/')[-1] == repo_name) {
          // build triggered by Gerrit -> use code from Gerrit
          repo_settings['branches'] = [[name: GERRIT_PATCHSET_REVISION]]
          repo_settings['userRemoteConfigs'][0]['refspec'] = GERRIT_REFSPEC
          repo_settings['userRemoteConfigs'][0]['url'] = "${GERRIT_URL}/${GERRIT_PROJECT}.git"
        } else {
          // build not triggered by Gerrit -> use code from GitLab
          repo_settings['branches'] = [[name: repo['branch']]]
          repo_settings['userRemoteConfigs'][0]['url'] = "${GITLAB_URL}:${repo['project']}.git"
        }
        checkout(repo_settings)
        lastChanges since:'LAST_SUCCESSFUL_BUILD', vcsDir:repo['relativeTargetDir']
      }
    }
  } catch(err) {
    echo "Caught: ${err}"
    currentBuild.result = 'Failure'
  }

  // load actual Jenkinsfile from pipeline repo
  load 'Jenkinsfile'
}

 

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

rmpestano@gmail.com (JIRA)

unread,
Oct 11, 2018, 9:10:01 AM10/11/18
to jenkinsc...@googlegroups.com
Rafael Pestano commented on Bug JENKINS-49627
 
Re: Last Changes Plugin shows git changes only in the first directory of the multidirectory pipeline

Hi Anastasiia Vlaskina,

sorry for the delay on replying.

One way to solve your problem I can think now is to send the diff of each repo as an email attachment because the plugin was not designed to work with multiple repositories. Following is an example of how to send the diff as email (taken from plugin docs):

 checkout(repo_settings)
def publisher = LastChanges.getLastChangesPublisher "LAST_SUCCESSFUL_BUILD", "SIDE", "LINE", true, true, "", "", "", repo['relativeTargetDir'], ""
                    publisher.publishLastChanges()
                    def changes = publisher.getLastChanges()
                    def diff = changes.getDiff()
                    writeFile file: 'build.diff', text: diff
                    emailext (
                      subject: "Sending diff of Job '${env.JOB_NAME} #${env.BUILD_NUMBER}'",
                      attachmentsPattern: '**/*.diff',
                      mimeType: 'text/html',
                      body: """<p>See attached diff of '${env.JOB_NAME} [${env.BUILD_NUMBER}]'.:</p>
                        <p>Check rich diff at <a href="${env.BUILD_URL}/last-changes">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
                      to: "rmpe...@gmail.com"  )

               }

You'll need email ext plugin installed.

I hope it helps.

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

rmpestano@gmail.com (JIRA)

unread,
Oct 11, 2018, 9:11:06 AM10/11/18
to jenkinsc...@googlegroups.com
Rafael Pestano edited a comment on Bug JENKINS-49627
Hi [~anastasiiavlaskina],


sorry for the delay on replying.

One way to solve your problem I can think now  is to send the diff  of  each repo as an email attachment because the plugin was not designed to work with multiple repositories. Following is an example of how to send the diff as email (taken from [plugin docs|https://github.com/jenkinsci/last-changes-plugin#sending-the-diff-as-email]):

{code}

checkout(repo_settings)
def publisher = LastChanges.getLastChangesPublisher "LAST_SUCCESSFUL_BUILD", "SIDE", "LINE", true, true, "", "", "", repo['relativeTargetDir'], ""
                    publisher.publishLastChanges()
                    def changes = publisher.getLastChanges()
                    def diff = changes.getDiff()
                    writeFile file: 'build.diff', text: diff
                    emailext (
                     subject: "Sending diff of Job '${env.JOB_NAME} #${env.BUILD_NUMBER}'",
                     attachmentsPattern: '**/*.diff',
                     mimeType: 'text/html',
                     body: """<p>See attached diff of '${env.JOB_NAME} [${env.BUILD_NUMBER}]'.:</p>
                     <p>Check rich diff at <a href="${env.BUILD_URL}/last-changes">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
                     to: " rmpestano yourteam @ gmail mail .com"  )

               }
{code}

You'll need  [email ext plugin|https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin] installed.

I hope it helps.

baisani.sivanarayana@gmail.com (JIRA)

unread,
Oct 28, 2019, 11:17:03 AM10/28/19
to jenkinsc...@googlegroups.com

any progress with the multi repo support for this plugin?

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages