Skip to content

Instantly share code, notes, and snippets.

View jonbrohauge's full-sized avatar
😎
Breathing, I hope

Jon Brohauge jonbrohauge

😎
Breathing, I hope
View GitHub Profile
@jonbrohauge
jonbrohauge / scan-organizations.adoc
Last active June 20, 2022 11:29
A way to automatically populate one or more GitHub Organizations on a Jenkins instance

A way to automatically populate one or more GitHub Organizations on a Jenkins instance

This document contains the way that I solved a specific issue. The issue was to populate one or more GitHub Organizations on a Jenkins instance upon initial start up.

Back story

To ensure compliance with audit, security, maintenance, and general sanity, my team is tasked with ensuring our 200+ developer have access to clean and up to date Jenkins instances.

The way we solve this is by having a locally developed portal that acts as an order form. Basically any developer can order an instance by supplying the request name of the instance and a list of one or more GitHub Organizations (from our internal GitHub Enterprise) they wish to use on the instance.

@jonbrohauge
jonbrohauge / setJenkinsUrl.groovy
Created August 18, 2020 10:24
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()}/")