jenkinskubernetes-helmjcasc

Provide external yaml file to JCasC configScripts


I am configuring my Jenkins instance using jenkins-helm chart (https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/VALUES_SUMMARY.md#jenkins-configuration-as-code-jcasc)

Currently Jenkins config is provided in values.yaml as:

jenkins:
  controller:
    JCasC:
      configScripts:
        key1:|-
          <a-very-big-yaml-value>

Is there a way to import this 'big-yaml-value' from separate yaml file, as it will enhance maintainability of code for us.


Solution

  • Based on previous answers, Here is an example how I made it work with multiple configuration yaml files to load into JCasC, using terraform:

    Jenkins module folder:
    -- configs
       - kubernetes.yaml
       - default-config.yaml
       ...
    -- main.tf
    -- values.yaml
    

    values.yaml:

       controller:
          JCasC:          
            defaultConfig: false
          persistence:
            enabled: true
            existingClaim: efs-claim-jenkins
          volumes:
            - name: jenkins-custom-casc-config
              configMap:
                name: jenkins-custom-casc-config
          mounts:
            - mountPath: /var/jenkins_home/casc_configs/custom
              name: jenkins-custom-casc-config
              readOnly: true
    

    main.tf:

    resource "kubernetes_config_map" "jenkins-custom-casc-config" {
      metadata {
        name      = "jenkins-custom-casc-config"
        namespace = "jenkins"
      }
    
      data = {
        for file in local.config_files :
        basename(file) => file("${path.module}/configs/${file}")
      }
    }