Job parameter as Selectbox with items from database

65 views
Skip to first unread message

Andrey Yeremenko

unread,
May 16, 2017, 2:23:54 PM5/16/17
to Jenkins Users
Hello guys!

Our team has experience with Jenkins. But first time we get a task when we need to connect to database for getting list of values for select box, which should be build parameter.

We found https://plugins.jenkins.io/extensible-choice-parameter which has “System Groovy Choice parameter”.  So a hope was to connect by groovy to mysql and get a list with needed parameters with needed filtering. But we get
Failed to execute script
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod groovy.sql.Sql newInstance java.lang.String java.lang.String java.lang.String java.lang.String
at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectStaticMethod(StaticWhitelist.java:192)

This is more or less predictably because of security reason…

How should such task be done right?

I can see https://wiki.jenkins-ci.org/display/JENKINS/Database+Plugin and https://plugins.jenkins.io/database-mysql but I have not understood if they can help in this task…

Please advice.

Best regards,
Andrey

Sébastien Hinderer

unread,
May 17, 2017, 4:18:00 AM5/17/17
to Jenkins Users
Hello Andrey,

I think I saw a similar discussion on the list around the end of April.
I can't remember the details well but I think there is a solution
involving a plugin that lets you control what other scripts are allowed
to do. If you lookup the list archive for htis period I'm pretty sure
you will find what you are looking for.

Best wishes,

Sébastien.

chuang...@gmail.com

unread,
May 3, 2018, 9:28:35 AM5/3/18
to Jenkins Users
I have same problem, when I used extends-choice-paramter plugin, I finished groovy script use mysql database to query select list , but I failed!

Reply all
Reply to author
Forward
0 new messages