jenkinsci / last-changes-plugin

https://plugins.jenkins.io/last-changes
https://plugins.jenkins.io/last-changes/
31 stars 28 forks source link

pipeline - multi git support #42

Open ghost opened 6 years ago

ghost commented 6 years ago

Previous version of the plugin was not supporting multi-scm plugin (job with multiple git)

Has this been considered with the update to support pipleline? I do not see any example using list of git repository

rmpestano commented 6 years ago

Hi,

Currently it only support one vcsDir, see here.

In case we support multiple repositories, how we'll perform the diff? One diff per repository? Diffs between repos?

Would you detail more what you expect?

Thank you.

ghost commented 6 years ago

Hi

Simpliest would be to do as to day and simply list all files (adding repositoryname in the report) As lon as you expect repositories to have same file name example repo1/pom.xml will probably exists in repo2/pom.xml

More complex implementation would be to group files per repo

Last summer, I had a student doing a prototype using old version based on MultiSCM plugin

As we played with the prototype we ecountered a major issue with the code. We are working in a Slave-Master environment and some of our git repos have over 1G of data. 1) The plugin was adding extra time to complete the job - copying whole content of the repo back to the main Jenkins server (and filling the file system of the main Jenkins server because of all the jobs copying git repo for nothing) 2) when we were trying to view the diff, jenkins was again trying to copy (or clone) the data to compare (not sure if this was caused by changes student made to the code )

I think the final solution (if remember well) was to generate the diff xml (html) on the slave and only backup those files back to the main Jenkins server workspace

attach is the code the student did (in August 2017) code compiles but some tests fails: multi-last-changes-plugin.tar.gz

Thanks!

rmpestano commented 6 years ago

Hi, thanks for detailing.

A lot has changed since August 2017, e.g since v2.2 we are removing copied vcs dir, see issue #29 for details.

I think supporting multiple repositories would bring extra complexity (e.g We probably would need a new UI for showing multiple repositories diff, a change on the model classes and extra parameters to the configuration to support it) for a very specific case (I may be wrong here but I think multi repository projects are not so common).

Anyway, I can reopen the issue and discuss this feature if you or anyone else really need this. And I will review PRs and accept them if the solution is simpler than what I imagine now.

ghost commented 6 years ago

pipeline does not limit us to 1 git repo, don't see why you plugin does not follow pipeline :-/

ghost commented 6 years ago

Hi Rafael yes, I would need it. our code is split on multiple repo and to this plugin would be usefull to track issue. let me know if I open a new issue thanks

rmpestano commented 6 years ago

Reopening, I'll not implement it but I can help someone willing to.

astifter commented 5 years ago

This is interesting for us as well. Any hints on where to start poking around?

rmpestano commented 5 years ago

Hi @astifter,

I've just created a contributors guide, see here.

I hope it helps.

perplexabot commented 5 years ago

Would I be wrong if I said an easy approach to implement this feature is to have it so that the plugin is called as such from the pipeline?:

node('builder-01'){
    stage('test'){
        deleteDir()
        dir('build-scripts'){
            git branch: 'master', url: 'git@github.someplace.com:software-team/build-scripts.git'
            //do stuff, who cares.
        }
        dir('manifest'){
            git branch: 'master', url: 'git@github.someplace.com:software-team/manifest.git'
            //do stuff, who cares.
        }
    }

    stage("last-changes-build-scripts") {
        dir('build-scripts'){
            git branch: 'master', url: 'git@github.someplace.com:software-team/build-scripts.git'
        }
        def publisher = LastChanges.getLastChangesPublisher "PREVIOUS_REVISION", "SIDE", "LINE", true, true, "", "", "", "", ""
              publisher.publishLastChanges()
              def changes = publisher.getLastChanges()
              println(changes.getEscapedDiff())
              for (commit in changes.getCommits()) {
                  println(commit)
                  def commitInfo = commit.getCommitInfo()
                  println(commitInfo)
                  println(commitInfo.getCommitMessage())
                  println(commit.getChanges())
              }
      }

    stage("last-changes-manifest") {
        dir('manifest'){
            git branch: 'master', url: 'git@github.someplace.com:software-team/manifest.git'
        }
        def publisher = LastChanges.getLastChangesPublisher "PREVIOUS_REVISION", "SIDE", "LINE", true, true, "", "", "", "", ""
              publisher.publishLastChanges()
              def changes = publisher.getLastChanges()
              println(changes.getEscapedDiff())
              for (commit in changes.getCommits()) {
                  println(commit)
                  def commitInfo = commit.getCommitInfo()
                  println(commitInfo)
                  println(commitInfo.getCommitMessage())
                  println(commit.getChanges())
              }
      }
}

Currently, if the above code is run in a Jenkins pipeline, two View Last Changes entries appear on the left side of the job, but both are of the last repo/branch checked out. Without reading through the plugin's code, I feel like only minor modifications are required to have the two View Last Changes entries show the respective diffs. Would this be a practical approach?

It would be extra nice if we could append a suffix to the View Last Changes entries so they are distinguishable.

vitara-jaskulski commented 1 year ago

Have there been any updates made on this issue?

This plugin would be great for what I need, but I'm dealing with two repos: A main one, and a sub repository (similar to what @perplexabot has going on)

rmpestano commented 1 year ago

Hey folks, if you you want to hack it I'm happy to review and try to guide you but it's been a long time since the plugin is not updated, maybe we first need to upgrade the dependencies before working on this