jenkinsci / add-changes-to-build-changelog-plugin

This plugin was aimed at adding changes to a Jenkins build that didn't come from SCM information. Maybe the changes were calculated outside of Jenkins, but someone wanted to show those changes in the Jenkins UI.
https://plugins.jenkins.io/add-changes-to-build-changelog/
MIT License
2 stars 1 forks source link

Perforce Changeset Compatibility #10

Open SrustikGowda opened 1 month ago

SrustikGowda commented 1 month ago

What feature do you want to see added?

We are using perforce as scm and it would be nice if perforce changeset capability is added

Upstream changes

No response

Are you interested in contributing this feature?

No response

danielomoto commented 3 weeks ago

Thanks for the suggestion! That is a great idea and I think it would make the plugin more useful. Unfortunately, I may not have time to implement it anytime soon. I apologize for that. I'm open to pull requests though for anyone that wants to take a stab at it.

SrustikGowda commented 3 weeks ago

Hi,

Can you suggest some of the steps needs to followed so that we can test and raise a PR?

Regards Srustik D

On Sun, 18 Aug, 2024, 12:08 pm danielomoto, @.***> wrote:

Thanks for the suggestion! That is a great idea and I think it would make the plugin more useful. Unfortunately, I may not have time to implement it anytime soon. I apologize for that. I'm open to pull requests though for anyone that wants to take a stab at it.

— Reply to this email directly, view it on GitHub https://github.com/jenkinsci/add-changes-to-build-changelog-plugin/issues/10#issuecomment-2295138030, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATQRMQQQ7BNGKWQZJYKNOXTZSA6NPAVCNFSM6AAAAABMOQ26DOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJVGEZTQMBTGA . You are receiving this because you authored the thread.Message ID: <jenkinsci/add-changes-to-build-changelog-plugin/issues/10/2295138030@ github.com>

danielomoto commented 1 week ago

Hi @SrustikGowda,

Sorry for the late reply.

If it's still relevant, here is some information. The plugin is really simple at its core.

  1. Get the commits to add from the user in json form https://github.com/jenkinsci/add-changes-to-build-changelog-plugin/blob/528669f9383f6be5af8f233d898579d63596e439/src/main/java/io/jenkins/plugins/addchangestobuildchangelog/AddChangesToBuildChangelogStep.java#L75
  2. Convert that json into whatever text format the target scm plugin outputs (e.g. svn outputs as an xml and git outputs as a text file). https://github.com/jenkinsci/add-changes-to-build-changelog-plugin/blob/528669f9383f6be5af8f233d898579d63596e439/src/main/java/io/jenkins/plugins/addchangestobuildchangelog/CustomChange.java#L33
  3. Save this converted text as a file to the build directory just like the target plugin would (e.g. svn would save it as changelog.xml) https://github.com/jenkinsci/add-changes-to-build-changelog-plugin/blob/528669f9383f6be5af8f233d898579d63596e439/src/main/java/io/jenkins/plugins/addchangestobuildchangelog/AddChangesToBuildChangelog.java#L86
  4. Reload the build in jenkins https://github.com/jenkinsci/add-changes-to-build-changelog-plugin/blob/528669f9383f6be5af8f233d898579d63596e439/src/main/java/io/jenkins/plugins/addchangestobuildchangelog/AddChangesToBuildChangelog.java#L115

You could just open up a build that has checked out a perforce view and mimic outputting the same text/files and reload the build to see if it picked up your new changes. Then convert those manual steps into java code.

You could also do this without a plugin as well using something like a build's [reload](https://javadoc.jenkins-ci.org/hudson/model/Run.html#reload()) if you're using a Freestyle Build. e.g.

// Get build
def build = jenkins.model.Jenkins.instance.getItemByFullName("my job").getBuildByNumber(1234)
// Output text files to build directory
new File(build.artifactsDir.path.replace("archive", "") + "changelog").text = "commit abcdefg ..."
// Reload the build
build.reload()

Unfortunately the place I work at no longer uses perforce and I haven't touched it in years. Thus, I probably wouldn't be the best person to implement it.

Hope this was helpful.