Skip to content

Instantly share code, notes, and snippets.

@jonbrohauge
Created August 18, 2020 10:24
Show Gist options
  • Save jonbrohauge/4e9433759e1596fe7962087e17f888ab to your computer and use it in GitHub Desktop.
Save jonbrohauge/4e9433759e1596fe7962087e17f888ab to your computer and use it in GitHub Desktop.
How to set JenkinsURL on boot of Jenkins instance
import jenkins.model.*
jlc = JenkinsLocationConfiguration.get()
String virtualHost = System.getenv("VIRTUAL_HOST")
virtualHost = virtualHost.toLowerCase()
if (!virtualHost?.trim()) {
virtualHost = "[PLACE DEFAULT HOST HERE]"
}
jlc.setUrl("https://${virtualHost.toLowerCase()}/")
jlc.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment