Get URL property of Jenkins JDK auto installer

13 views
Skip to first unread message

Onno van der Straaten

unread,
Jan 28, 2020, 12:40:33 AM1/28/20
to Jenkins Users
Hi all,I am using a Groovy script to create auto-installers for JDK in my Jenkins instance. With a script similar to https://stackoverflow.com/questions/55353804/how-to-automate-maven-and-java-jdk8-installation-with-groovy-for-jenkins

This all works and is clear to me but now I want to create a script that queries Jenkins for JDKs that are already installed. I can get some of the information about installed JDKs but it is unclear how I can retrieve properties like the URL to the download JDK tar.gz and the label.

How can I get at that information in my Groovy script?

    import jenkins.model.*
    import hudson.model.*
    import hudson.tasks.*
    import hudson.tools.*
    import java.security.*
   
    def inst = Jenkins.getInstance()
    def desc = inst.getDescriptor("hudson.model.JDK")
   
      desc.getInstallations().each {
        println 'it.getName' + it.getName()
        println 'it.getBinDir' + it.getBinDir()
        println 'it.getExecutable' + it.getExecutable()
        println 'it.getJavaHome' + it.getJavaHome()
        println 'it.getProperties' + it.getProperties() //[hudson.tools.InstallSourceProperty@31c527ef]
      }
Reply all
Reply to author
Forward
0 new messages