Helm Chart

kind: helmChart

sourceconditiontarget

source

The Helm chart "source" retrieves the latest version of a Helm package.

condition

The Helm chart "condition" tests if a helm chart release exist.

target

The Helm chart "target" updates a helmchart and bump the chart metadata. It handle AppVersion, incremental version update and requirements.lock. It both works with helm chart located locally or on a git repository. If the helm chart is located locally, then chart name must be an absolute path to the chart.

Parameter

NameRequiredDefaultDescription

url

-

[S,C]Define url for remote Helm chart repository

name

-

[S,C,T]Define Helm chart package name.

version

Source

[S,C] Define Helm chart version.

file

values.yaml

[T] Define the file that needs to be updated

value

source

[T] Define the value that need to be present in helm chart file

key

-

[T] Define the key that need to be present in helm chart file

appversion

false

[T] Boolean that defines if the value should also be used for the AppVersion

versionincrement

minor

[T] Define the rule to automatically increment the helm chart version. It accept a comma separated list of major,minor,patch.

Example

updatecli.yaml
source:
  kind: helmChart
  spec:
    url: https://charts.jenkins.io
    name: jenkins
conditions:
  isPrometheuseHelmChartVersionAvailable:
    name: "Test if the prometheus helm chart is available"
    kind: helmChart
    spec:
      url: https://prometheus-community.github.io/helm-charts
      name: prometheus
      version: 11.16.5
  chartVersion:
    name: "jenkinsci/jenkins Helm Chart used"
    kind: yaml
    spec:
      file: "charts/jenkins/requirements.yaml"
      key: "dependencies[0].name"
      value: "jenkins"
    scm:
      github:
        user: "{{ .github.user }}"
        email: "{{ .github.email }}"
        owner: "{{ .github.owner }}"
        repository: "{{ .github.repository }}"
        token: "{{ requiredEnv .github.token }}"
        username: "{{ .github.username }}"
        branch: "{{ .github.branch }}"
targets:
  chartjenkins:
    name: Bump Jenkins Upstream Chart Version
    kind: helmChart
    spec:
      Name: "charts/jenkins"
      file: "requirements.yaml"
      key: "dependencies[0].version"
      versionIncrement: minor
    scm:
      github:
        user: "john"
        email: "john@example.com"
        owner: "olblak"
        repository: "charts"
        token: {{ requiredEnv .github.token }}
        username: "john"
        branch: "master"

What it says:

Source

Retrieve the version from the Jenkins helm chart repository located on "https://charts.jenkins.io" ⇒ 2.7.1

Conditions

Then it tests two conditions.

  1. Test a helmchart condition, "Is the prometheus helm chart version "11.16.5" is available from https://prometheus-community.github.io/helm-charts? ⇒ Yes, proceed, No then abort

  2. - Test a yaml condition, "Do we have an yaml file named "charts/jenkins/requirements.yaml" with the key dependencies that contains an array where the first element is set to "jenkins" ?" ⇒ Yes, proceed, No then abort

Targets If all conditions are met, we bump the Jenkins upstream version into our local one. We remove the requirements.lock if it exists. We bump the chart version using the incremental version (patch,minor,major). Finally we commit our changes and then open a pull request on Github.

Edit this page on GitHub