Referencing local resources in plugin does not work (resURL)

13 views
Skip to first unread message

r.baeris...@gmail.com

unread,
Sep 2, 2020, 9:54:48 AM9/2/20
to Jenkins Developers
Hello all

I'm trying to get out a new release of the https://github.com/jenkinsci/docker-swarm-plugin

One change I am trying is to embedd all css/js files to it can be used in an offline jenkins instance.

For this, I added the files into the webapp folder and then referenced them like:

            <link rel="stylesheet" href="${resURL}/plugin/docker-swarm/css/clr-ui.min.css" />
            <link rel="stylesheet" href="${resURL}/plugin/docker-swarm/css/clr-icons.min.css" />
            <script src="${resURL}/plugin/docker-swarm/js/custom-elements.min.js"></script>
            <script src="${resURL}/plugin/docker-swarm/js/clr-icons.min.js"></script>
            <script src="${resURL}/plugin/docker-swarm/js/Chart.min.js"></script>
            <script src="${resURL}/plugin/docker-swarm/js/chartjs-plugin-datalabels.js"></script>

The problem is that if a jenkins instance is in a subfolder (JENKINS_OPTS / prefix=/jenkins) it does not find the resources as they now just point to /plugin/docker-swarm/... So it seems that either resUrl is not resolved or it is just empty.

Can anyone please help me here?

Best Regards
Roman

Jesse Glick

unread,
Sep 2, 2020, 10:34:25 AM9/2/20
to Jenkins Dev
On Wed, Sep 2, 2020 at 9:54 AM r.baeris...@gmail.com
<r.baeris...@gmail.com> wrote:
> it seems that either resUrl is not resolved or it is just empty.

No promises, but if you want a helpful response your chances are much
better if you link to an open pull request demonstrating the attempted
change.

Gavin Mogan

unread,
Sep 2, 2020, 12:17:13 PM9/2/20
to Jenkins Developers
It's unlikely that resurl would break without anyone else noticing. It's used all over.

What kind of page are you making (what filename and class).

I know if your not inside of a layout tag it won't be defined. But you shouldn't need to call layout unless your making a completely new page

--
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/CANfRfr1Jvx6abnqkABOjgs5C2Fuzdu2ptTwvx%3DJT8tRpWRSNZg%40mail.gmail.com.

r.baeris...@gmail.com

unread,
Sep 3, 2020, 1:25:02 AM9/3/20
to Jenkins Developers
I found out that in the jelly template, there is a new html/head/body tag and the  <l:layout>  was just inside the body. I moved everything inside  <l:layout> and now it correctly resolves the resURL. I will create a separate issue I have with the additional html/head/body which I need in my case.
Reply all
Reply to author
Forward
0 new messages