Creating Custom Jenkins Images

Jenkins is well templated, you just need to define what you are looking for.

Jenkinsfile
pom.xml

Jenkinsfile

mavenBuild()

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <parent>
    <groupId>io.practiv.stable.anvil</groupId>
    <artifactId>anvil-parent</artifactId>
    <version>1.1</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>

  <groupId>io.practiv.stable.anvil</groupId>
  <artifactId>anvil-jenkins</artifactId>
  <version>1.999-SNAPSHOT</version>

  <name>${project.artifactId}</name>
  <description>Packaged Jenkins for Practiv BUILD</description>

  <build>
    <plugins>
      <plugin>
        <groupId>io.repaint.maven</groupId>
        <artifactId>tiles-maven-plugin</artifactId>
        <version>2.34</version>
        <configuration>
          <tiles>
            <tile>io.practiv.stable.anvil:anvil-tile-build:[1,2)</tile>
            <tile>io.practiv.stable.chalk:chalk-jenkins:[20,21)</tile>
            <tile>io.practiv.stable.dust:dust-legacy-scripted:[16,17)</tile>
            <tile>io.practiv.stable.dust:dust-maven-scripted:[16,17)</tile>
            <tile>io.practiv.stable.dust:dust-startup:[14,15)</tile>
            <tile>io.practiv.stable.dust:dust-notify-google-chat:[5,6)</tile>
          </tiles>
        </configuration>
      </plugin>

    </plugins>
  </build>
</project>

src/main/kubernetes/secret.template

apiVersion: v1
kind: Secret
metadata:
  name: ${project.artifactId}-secret-v${project.version}
  namespace: ${environment}
type: Opaque
data:
  credentials.yaml: |
    credentials:
    githubOauth:
      name: Practiv GitHub
      clientId: ${jenkins/githubOauth.clientId}
      secret: ${jenkins/githubOauth.secret}

src/main/kubernetes/persisitent-volume.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  labels:
    failure-domain.beta.kubernetes.io/zone: ${jenkinsReplicationZones}
  name: ${environment}-jenkins-home
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 50Gi
  gcePersistentDisk:
    pdName: ${environment}-jenkins-home
    fsType: ext4
  storageClassName: practiv-fast-replicated

src/main/kubernetes/persisitent-volume-claim.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-home
  namespace: ${environment}
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
  volumeName: ${environment}-jenkins-home
  storageClassName: practiv-fast-replicated