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

Compare current workspace diff with remote #10

Open
ltozi opened this issue Sep 29, 2017 · 3 comments
Open

Compare current workspace diff with remote #10

ltozi opened this issue Sep 29, 2017 · 3 comments
Labels
enhancement Improvement or new feature

Comments

@ltozi
Copy link

ltozi commented Sep 29, 2017

I'm in a particular case where I have to deploy sources from one repository (our deploy repo) to customer repository (release source to customer).

I saw that scm is caluclated where the scm is the one where files were committed and for which a build trigger occurred:

https://github.com/jenkinsci/last-changes-plugin/blob/master/src/main/java/com/github/jenkins/lastchanges/LastChangesPublisher.java#L155

In my pipeline I do a second scm checkout and I would like to diff in a way like this:

svn diff -r PREV:BASE | diff2html -i stdin -s side -F report.html

Where BASE is workspace with incoming new changes for the customer repo.

Is it possible to point to a different repo to show diff?

Thanks,
Luigi

@rmpestano
Copy link
Contributor

Hi @ltozi,

I think it is possible but it needs to be implemented, the svn diff is done here, it gets source and target revisions from the same repository:

diff.setSources(SvnTarget.fromURL(repository.getLocation(), SVNRevision.create(previousRevision)),
                    SvnTarget.fromURL(repository.getLocation(), SVNRevision.create(currentRevision)));

in above example both source and target are from the same repo but it could be different ones.

Now the question is, how can we pass the second repository information to the plugin? besides the url you'll also need to pass the credentials.

Currently we don't need to worry about that because we get from build trigger.

Having said that if you provide a PR with this implemented in both SVN and GIT I can review and accept the pull request.

@rmpestano rmpestano added the enhancement Improvement or new feature label Sep 29, 2017
@ltozi
Copy link
Author

ltozi commented Sep 29, 2017

Hi @rmpestano,

I'm not a "Jenkins pipeline guru", but what do you think if lastChanges plugin could take scm reference directly from the directory where the command is run?

Example:
`
//1
checkout scm
lastChanges() //How actually works

//2
dir("customs/svn/dir") {
checkout scm //with jenkins provided credential etc...
lastChanges()
}

//3
dir("customs/svn/dir") {
def scmObj = checkout scm //with jenkins provided credential etc...
//use scmObj in lastChanges?
}
`

@rmpestano
Copy link
Contributor

rmpestano commented Sep 30, 2017

Hi, I'm really out of time to try and implement that but if you will here are the things that must be changed in order to make //3 work:

You need to add another parameter (of type scm) here and if it is not null then call last change here passing the additional repository and later create another method here which receives two repositories as parameters and finnaly call the diff using the additional repository as I commend here.

Also to accept the PR there must be a test here.

Thank you for the feedback.

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

No branches or pull requests

2 participants