For the record: I fixed the problems now. JS now loads correctly in Jenkins and
in Jenkins test harness.
I needed to initialize the variables ${resURL} manually in each Jelly file:
<j:new var="h" className="hudson.Functions" />
${h.initPageVariables(context)}
Then the new UI JS plugins can be simply referenced by using an adjunct like
<st:adjunct includes="io.jenkins.plugins.bootstrap4“/>
This resolves all JS and CSS files below
${resURL}/plugin/bootstrap4-api/*
An example of such a view is available at
https://github.com/jenkinsci/forensics-api-plugin/blob/1da271633a776e9fcee586861414a20f726ffd38/src/main/resources/io/jenkins/plugins/forensics/miner/ForensicsViewModel/index.jelly
<https://github.com/jenkinsci/forensics-api-plugin/blob/1da271633a776e9fcee586861414a20f726ffd38/src/main/resources/io/jenkins/plugins/forensics/miner/ForensicsViewModel/index.jelly>
I will prepare a blog post that introduces these new JS plugins in the next
couple of weeks…
> Am 28.11.2019 um 21:51 schrieb Ullrich Hafner <[email protected]>:
>
> Ok, I found the problem (but still have no solution on how to proceed):
>
> In the adjunct jelly file I load the JS files in using commands like:
> <script type="text/javascript"
> src="${resURL}/plugin/jquery3-api/webjars/jquery.min.js“/>
>
> The part ${resURL} is correctly evaluated in Jenkins but not in the test
> harness (where „jenkins“ is used as context root). Actually ${resURL} is
> empty in the adjunct. So I think if Jenkins will use a different context root
> it will not work there as well.
>
> Then I realized that other adjuncts use something like:
> <script src="${it.packageUrl}/timeline_js/timeline-bundle.js"
> type="text/javascript" />
>
> After changing that in my plugins the path is correctly expanded to something
> like
> http://localhost:8080/adjuncts/3e890174/io/jenkins/plugins/bootstrap4/js/bootstrap.min.js
>
> <http://localhost:8080/adjuncts/3e890174/io/jenkins/plugins/bootstrap4/js/bootstrap.min.js>
>
> However the resources are not found, they are rather exposed as
> http://localhost:8080/plugin/bootstrap4-api/io/jenkins/plugins/bootstrap4/js/bootstrap.min.js
>
> <http://localhost:8080/plugin/bootstrap4-api/io/jenkins/plugins/bootstrap4/js/bootstrap.min.js>
>
> After some more digging I realized that the adjuncts are actually libraries
> and no plugins. So this seems to be not compatible.
>
> What is the right way to tackle this problem?
> Should I locate JS libraries like bootstrap in a Jenkins plugin or in a
> library (jar) that I am depending on?
> Should I refer to the JS files using something like <st:adjunct
> includes="io.jenkins.plugins.bootstrap4“/> or should I better define a tag
> lib that includes the JS files using simple script tags?
> Or is there even another way that makes sense?
>
>> Am 21.11.2019 um 01:35 schrieb Jesse Glick <[email protected]
>> <mailto:[email protected]>>:
>>
>> On Wed, Nov 20, 2019 at 5:37 PM Ullrich Hafner <[email protected]
>> <mailto:[email protected]>> wrote:
>>> Is this a known limitation of the test harness? Or is this a bug I can try
>>> to fix in the test harness
>>
>> Since you are probably the first to encounter the issue, I would guess
>> it is a bug. Whether it is fixable, I have no idea offhand.
>>
>> --
>> 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 [email protected]
>> <mailto:[email protected]>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2iJdgEEppzRKTwfYYWzUHMnPJKFp5QcRKLe1teCYy5JA%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2iJdgEEppzRKTwfYYWzUHMnPJKFp5QcRKLe1teCYy5JA%40mail.gmail.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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/6F77F600-B9B2-4FAD-8DF9-6A025DB6C294%40gmail.com.