Adding Javascript to config.groovy

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding Javascript to config.groovy

Parichay Barpanda
Hi,

I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

Thanks and Regards,
Parichay

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Gavin Mogan
Whats a config.groovy compared to config.jelly? Are you writing a plugin using groovy?

On Thu, May 21, 2020 at 12:54 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

Thanks and Regards,
Parichay

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuvEw-Lm1BqTsep-f%3DezAVWnJuyA1oVs62OksgozHM0R_w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Parichay Barpanda
Yes. See https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/master/src/main/resources/io/jenkins/plugins/gitlabserverconfig/servers/GitLabServer/config.groovy

On Friday, May 22, 2020 at 1:26:09 AM UTC+5:30, Gavin Mogan wrote:
Whats a config.groovy compared to config.jelly? Are you writing a plugin using groovy?

On Thu, May 21, 2020 at 12:54 PM Parichay Barpanda <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="f7Mz6Qa-AgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
Hi,

I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

Thanks and Regards,
Parichay

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="f7Mz6Qa-AgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e4d2b0b7-dc5d-4ee3-b449-7bb90b5f73dd%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Gavin Mogan
Oh wow, I didn't know that was a thing.

Apparently you can use raw()


My grepping didn't turn up any other options. I'd be concerned that raw() isn't doing any xss escaping though, so someone else will have to speak to that.

On Thu, May 21, 2020 at 1:07 PM Parichay Barpanda <[hidden email]> wrote:
Yes. See https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/master/src/main/resources/io/jenkins/plugins/gitlabserverconfig/servers/GitLabServer/config.groovy

On Friday, May 22, 2020 at 1:26:09 AM UTC+5:30, Gavin Mogan wrote:
Whats a config.groovy compared to config.jelly? Are you writing a plugin using groovy?

On Thu, May 21, 2020 at 12:54 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

Thanks and Regards,
Parichay

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e4d2b0b7-dc5d-4ee3-b449-7bb90b5f73dd%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuumyANSTw7gfmV5K9GHifOTdGMEMabyhxk7mOPDX6CS6A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Parichay Barpanda
Thanks. I first saw groovy style config in GitHub Plugin and feel it more convenient over jelly because lack of IDE support make tags unreadable.

On Fri, May 22, 2020 at 1:54 AM 'Gavin Mogan' via Jenkins Developers <[hidden email]> wrote:
Oh wow, I didn't know that was a thing.

Apparently you can use raw()


My grepping didn't turn up any other options. I'd be concerned that raw() isn't doing any xss escaping though, so someone else will have to speak to that.

On Thu, May 21, 2020 at 1:07 PM Parichay Barpanda <[hidden email]> wrote:
Yes. See https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/master/src/main/resources/io/jenkins/plugins/gitlabserverconfig/servers/GitLabServer/config.groovy

On Friday, May 22, 2020 at 1:26:09 AM UTC+5:30, Gavin Mogan wrote:
Whats a config.groovy compared to config.jelly? Are you writing a plugin using groovy?

On Thu, May 21, 2020 at 12:54 PM Parichay Barpanda <[hidden email]> wrote:
Hi,

I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

Thanks and Regards,
Parichay

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e4d2b0b7-dc5d-4ee3-b449-7bb90b5f73dd%40googlegroups.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuumyANSTw7gfmV5K9GHifOTdGMEMabyhxk7mOPDX6CS6A%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWANFnS91D6O%2Bw8evDSuhUDOCnPKxD7iFWqP2Ktre-wi96A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Daniel Beck-2

On Thu, May 21, 2020 at 10:35 PM Parichay Barpanda <[hidden email]> wrote:
because lack of IDE support make tags unreadable.


There are IDE plugins adding support for this.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7Pt%2BnhMarvi5eu%2BJZ1ghCnQZUh-vxn-KJi3uzybO4Vr%3DUPA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Jesse Glick-4
In reply to this post by Parichay Barpanda
On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda
<[hidden email]> wrote:
> I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

You are better off using `st.adjunct` so you can keep `*.js` and/or
`*.css` files separate.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1qVA_3zZJPwv74AktBKSGoPqxkQ2JPg8R9zFh_-0k-oA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Esther Alvarez
On Thursday, May 28, 2020 at 1:27:54 PM UTC+2, Jesse Glick wrote:
On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="p88aFjdKAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
> I am looking for a way to add Javascript to config.groovy files in my resources. It is possible to do so in jelly with <script> tags. Is it possible to write JS in groovy?

You are better off using `st.adjunct` so you can keep `*.js` and/or
`*.css` files separate.

I can not agree more with this. Keeping javascript code in a .js file is the best approach. Writing javascript using jelly (the script tag option) can seem easier, but it leads to a lot of problems and XSS attacks, and you will have to escape some special XML characters as well (&,<,>) which is a pain.

To pass around data from jelly to javascript, you can write "data-" attributes in HTML tags with jelly and then load them with javascript. Here some examples about how to do it: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4a81ba7d-15cd-4af1-930f-9f5844c67186%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Javascript to config.groovy

Daniel Beck


> On 29. May 2020, at 11:47, Esther Alvarez <[hidden email]> wrote:
>
> To pass around data from jelly to javascript, you can write "data-" attributes in HTML tags with jelly and then load them with javascript. Here some examples about how to do it: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

Also https://jenkins.io/doc/developer/security/xss-prevention/

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/2DB7CC74-80B0-4E42-8978-216B109CA46D%40beckweb.net.