API to render links with RepositoryBrowser

43 views
Skip to first unread message

Ullrich Hafner

unread,
Sep 15, 2020, 4:56:47 PM9/15/20
to Jenkins Developers
SCM plugins like the Git plugin show links to the changes in the hosted repositories (e.g. to GitHub changes).
Is there a generic API available to obtain those links so I can embed them in my plugin as well?
E.g., in the warnings plugin I’m showing the Git SHA of the commit that introduced a warning (currently as plain text).
It would be helpful if one could navigate to the GitHb source directly from that SHA.


Tim Jacomb

unread,
Sep 16, 2020, 1:28:45 AM9/16/20
to jenkin...@googlegroups.com

--

You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/130F9688-8F61-4FC8-A1C1-7457677F0C35%40gmail.com.

James Nord

unread,
Sep 16, 2020, 4:38:22 PM9/16/20
to Jenkins Developers

there is also the  link for the URL in the changeling which is controlled by the RepositoryBrowser implementation.

Ullrich Hafner

unread,
Sep 21, 2020, 6:18:45 PM9/21/20
to Jenkins Developers
Seems there is a scm.getEffectiveBrowser() method which returns something useful (I tried scm.getBrowser() but this method returns null).

A repository browser operates on a ChangeSet. How can I create one from a simple git commit hash? 

Jesse Glick

unread,
Sep 22, 2020, 12:55:46 PM9/22/20
to Jenkins Dev
On Mon, Sep 21, 2020 at 6:18 PM Ullrich Hafner <ullrich...@gmail.com> wrote:
> A repository browser operates on a ChangeSet. How can I create one from a simple git commit hash?

You do not. It would be added to a `Run` during `SCM.checkout`.

Ullrich Hafner

unread,
Sep 22, 2020, 2:19:22 PM9/22/20
to Jenkins Developers
Hmm, but how do I get the link for a commit hash then? There is no API to obtain change sets from the builds, or am I missing something obvious?
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1JyHhsS%3DcQr_KVMXdwGWXXasCx82ch%2B5F0WLRL8CR1Ag%40mail.gmail.com.

Jesse Glick

unread,
Sep 23, 2020, 12:31:57 PM9/23/20
to Jenkins Dev
On Tue, Sep 22, 2020 at 2:19 PM Ullrich Hafner <ullrich...@gmail.com> wrote:
> There is no API to obtain change sets from the builds

https://javadoc.jenkins.io/jenkins/scm/RunWithSCM.html#getChangeSets--

Ullrich Hafner

unread,
Sep 23, 2020, 2:46:16 PM9/23/20
to Jenkins Developers
Seems that I am getting from one problem to the next :-( 

RunWithSCM.html#getChangeSets returns a list of changes in the current build. The links I want to create are commits that are not necessarily in the current build. The participating build may even be deleted because the commit is too old. RepositoryBrowser#getChangeSetLink(E changeSet) requires a ChangeSet which seems to have no simple public constructor. 

Maybe my use cases needs some explanation: the warnings plugin shows blames with commit IDs where and when a warning has been introduced. 
And the Git forensics plugin shows statistics of all commits for a file. Currently I show the links in plain text. What I simply want for these files:

Input: a commit hash like: d70ffafe55c68dfebd7fee405ec451f1493c37bd




--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

Tim Jacomb

unread,
Sep 23, 2020, 2:58:54 PM9/23/20
to jenkin...@googlegroups.com
Can you use the ObjectMetadataAction?

Ullrich Hafner

unread,
Sep 23, 2020, 4:10:15 PM9/23/20
to Jenkins Developers
build.getAction(ObjectMetadataAction.class) returns null (at least for a FreeStyle job).


Am 23.09.2020 um 18:31 schrieb Jesse Glick <jgl...@cloudbees.com>:

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

Jesse Glick

unread,
Sep 23, 2020, 4:20:56 PM9/23/20
to Jenkins Dev
On Wed, Sep 23, 2020 at 2:46 PM Ullrich Hafner <ullrich...@gmail.com> wrote:
> RunWithSCM.html#getChangeSets returns a list of changes in the current build. The links I want to create are commits that are not necessarily in the current build.

Sorry, not something supported by existing Jenkins APIs I think.
Reply all
Reply to author
Forward
0 new messages