Jenkins job active choice parameters groovy script issue

Hi Team,

We have a Jenkins job with active choice parameter with groovy script.

Groovy script need to fetch the content of one of gitlab repository file using rest api.

The groovy script working fine from Jenkins server directly however same script not working when added under active choice parameter and getting error like proxy error.

Would like to know how does the groovy script runs in case of active choice parameter and where it get executed on server end and when same script working from the Jenkins server and not through active choice parameter

Jenkins Environment:
Jenkins Version: 2.387.3
OS: Linux - 4.18.0-372.9.1.el8.x86_64
Java: 17.0.3 - Red Hat, Inc. (OpenJDK 64-Bit Server VM)

Hi @suryareddy
can i get error log

Hi,

Thanks for supporting on this issue.

Groovy Script configured in active choice parameter,

def private_token = “XXXXXXXXXXXXX”

System.properties << [ ‘http.proxyHost’:‘XXXXXXXXXXXX’, ‘http.proxyPort’:‘xxxx’]

def url1= new URL(“https://gitlab.com/api/v4/projects/xxxxxxxxx/repository/branches?private_token=” + private_token).text

branches_list = new groovy.json.JsonSlurper().parseText(url1)

Here is the details of errors:

Fallback to default script…
java.net.UnknownHostException: gitlab.com
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:572)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:304)
at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:174)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:183)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:533)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:638)
at java.base/sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:380)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1242)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1665)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
at org.codehaus.groovy.runtime.ResourceGroovyMethods.configuredInputStream(ResourceGroovyMethods.java:2048)
at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:2134)

Error says it is unable to resolve gitlab.com to IP address.
Did you check whether proxy properties are properly set or not?

Try these as well:
System.setProperty(“http.proxyHost”, “Yourproxyhost”);
System.setPropery(“http.proxyPort”, “port”);

same proxy works with GitLab directly from jenkins server end…but failing to connect from active choice parameter groovy script

tried below but no luck,
System.setProperty(“http.proxyHost”, “Yourproxyhost”);
System.setPropery(“http.proxyPort”, “port”);