Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49627

Last Changes Plugin shows git changes only in the first directory of the multidirectory pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: last-changes-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.101
      Last Changes Plugin 2.6
    • Similar Issues:

      Description

      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'
      }
      

       

       

        Attachments

          Activity

          Hide
          rmpestano Rafael Pestano added a comment - - edited

          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: "yourteam@mail.com"  )
          
                         }
          

          You'll need email ext plugin installed.

          I hope it helps.

          Show
          rmpestano Rafael Pestano added a comment - - edited 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: "yourteam@mail.com" ) } You'll need email ext plugin installed. I hope it helps.
          Hide
          siva_baisani sivanarayana baisani added a comment -

          any progress with the multi repo support for this plugin?

          Show
          siva_baisani sivanarayana baisani added a comment - any progress with the multi repo support for this plugin?

            People

            Assignee:
            rmpestano Rafael Pestano
            Reporter:
            anastasiiavlaskina Anastasiia Vlaskina
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: