Adding Javascript to config.groovy

瀏覽次數:95 次
跳到第一則未讀訊息

Parichay Barpanda

未讀,
2020年5月21日 下午3:54:262020/5/21
收件者:Jenkins Developers
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

Gavin Mogan

未讀,
2020年5月21日 下午3:56:092020/5/21
收件者:Jenkins Developers
Whats a config.groovy compared to config.jelly? Are you writing a plugin using groovy?

--
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/11d2e5ed-89ce-4727-96f8-e0e62ef35576%40googlegroups.com.

Parichay Barpanda

未讀,
2020年5月21日 下午4:07:292020/5/21
收件者:Jenkins Developers


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 <parichay...@gmail.com> 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 jenkin...@googlegroups.com.

Gavin Mogan

未讀,
2020年5月21日 下午4:24:462020/5/21
收件者:Jenkins Developers
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.

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/e4d2b0b7-dc5d-4ee3-b449-7bb90b5f73dd%40googlegroups.com.

Parichay Barpanda

未讀,
2020年5月21日 下午4:35:572020/5/21
收件者:Jenkins Developers
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.

Daniel Beck

未讀,
2020年5月28日 清晨6:39:552020/5/28
收件者:JenkinsCI Developers

On Thu, May 21, 2020 at 10:35 PM Parichay Barpanda <parichay...@gmail.com> wrote:
because lack of IDE support make tags unreadable.


There are IDE plugins adding support for this.

Jesse Glick

未讀,
2020年5月28日 清晨7:27:542020/5/28
收件者:Jenkins Dev
On Thu, May 21, 2020 at 3:54 PM Parichay Barpanda
<parichay...@gmail.com> 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.

Esther Alvarez

未讀,
2020年5月29日 清晨5:47:062020/5/29
收件者:Jenkins Developers
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

Daniel Beck

未讀,
2020年5月30日 中午12:00:192020/5/30
收件者:jenkin...@googlegroups.com


> On 29. May 2020, at 11:47, Esther Alvarez <ealv...@cloudbees.com> 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/

回覆所有人
回覆作者
轉寄
0 則新訊息