Jelly question: How to construct the URL of a section on the Jenkins configuration page?

38 views
Skip to first unread message

Martin Weber

unread,
May 4, 2016, 4:26:43 PM5/4/16
to jenkins developers
Hi all,

I want to create a HTML-link on the job configuration page that directly
points to the corresponding tool installation section on *global*
configuration page. (Well, yes, this is teamcity inspired:-)

I know that
'${rootURL}/configure'
points to the config page, but how do I get the anchor on that page that
directly points to (for example) 'Maven installations' section?

From the breadcumb navigation on the config page, the URL would be
'http://localhost:8080/jenkins/configure#section45' on my jenkins instance,
but that seems to be very instance-specific.

In my case, I would like to get the URL of the config section contributed by
Java class "hudson.plugins.cmake.CmakeTool extends ToolInstallation".

TIA,
Martin

--
Cd wrttn wtht vwls s mch trsr.


Robert Sandell

unread,
May 6, 2016, 7:46:20 AM5/6/16
to jenkin...@googlegroups.com
Links in the side panels are implementations of Action. And you can add transient actions to jobs via the TransientActionFactory<Job> extension point.

In Jenkins 2.0 the Global Tool Configuration got put on a separate configuration page, like what has happened earlier with the Global Security Configuration.
Those pages are implementations of ManagementLink which extends Action. So you could try to just return that management link from your TransientActionFactory if the user has admin access.

/B

--
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/4219326.MqEhROkAH0%40linux.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Daniel Beck

unread,
May 6, 2016, 7:57:40 AM5/6/16
to jenkin...@googlegroups.com

> On 06.05.2016, at 13:46, Robert Sandell <rsan...@cloudbees.com> wrote:
>
> Links in the side panels are implementations of Action. And you can add transient actions to jobs via the TransientActionFactory<Job> extension point.

I think you're missing the point here. The problem isn't how to place the link, it's how to link to a specific section of the target form.

Robert Sandell

unread,
May 6, 2016, 9:15:43 AM5/6/16
to jenkin...@googlegroups.com
True, but since the specific section he mentioned to link to is gone in 2.0 I saw no need :)

But yea, something is adding those anchor points, but it's not lib/form/section.jelly so some magic javascript seems to be adding them after the jelly has been rendered.

/B

--
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.

For more options, visit https://groups.google.com/d/optout.

Robert Sandell

unread,
May 6, 2016, 9:38:31 AM5/6/16
to jenkin...@googlegroups.com
Ok, so those anchors are added by lib/form/breadcrumb-config-outline/init.js and it is just using a counter for each achor it adds, so it won't be easy to guess what that would be, there is a TODO marked in that file to make a more user friendly id, but who knows when someone will take that on :)

Instead In your case I would try to add my own, more deterministic anchors in a similar way as the breadcrumb init.js is doing that for example uses the backend id of the section (or fix the js in core to also use the id).

/B

Martin Weber

unread,
May 6, 2016, 9:39:58 AM5/6/16
to jenkin...@googlegroups.com
Am Freitag, 6. Mai 2016, 13:46:13 schrieb Robert Sandell:
> Links in the side panels are implementations of Action. And you can add
> transient actions to jobs via the TransientActionFactory<Job> extension
> point.
>
> In Jenkins 2.0 the Global Tool Configuration got put on a separate
> configuration page, like what has happened earlier with the Global Security
> Configuration.

So, if that is an a separate page now, I see no point to place a link on the
job page.

Martin Weber

unread,
May 6, 2016, 9:59:05 AM5/6/16
to jenkin...@googlegroups.com
Am Freitag, 6. Mai 2016, 15:15:38 schrieb Robert Sandell:
> True, but since the specific section he mentioned to link to is gone in 2.0
> I saw no need :)
>
> But yea, something is adding those anchor points, but it's not
> lib/form/section.jelly so some magic javascript seems to be adding them
> after the jelly has been rendered.

It is in lib/form/breadcrumb-config-outline/init.js

I inspected the generated config page and found a
<tr> element is generated for each section. The element has a _name_
attribute with a value derived from the tool descriptor.
For the JDK tool, it gives
<tr ... name="hudson-model-JDK">

W3C says, there is no name attribute allowed for <tr>, but it is allowed for
<a>.
Looks like someone already tried to generate an anchor here, but messed up the
jelly code.
Reply all
Reply to author
Forward
0 new messages