sourceconditiontarget

Description

The jenkins resource reads the Jenkins release metadata from https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml and returns a version from it.

source

Returns the latest version of the requested release line.

condition

Checks that version exists and that it belongs to the release line named by release.

target

Not supported - a target fails with Target not supported for the plugin Jenkins.

Note
An scm attached to a condition is ignored, with the warning SCM configuration is not supported for Jenkins condition.

Parameters

NameTypeDescriptionRequired
releasestring[s][c] Defines the release name. It accepts “stable” or “weekly”
versionstring[s][c] Defines a specific release version (condition only)
release

Either stable or weekly.

version

Condition only - the version being checked.

Release lines

The release line is derived from the shape of the version number, by counting dot-separated components:

ComponentsReleaseExample

2

weekly

2.426

3

stable (LTS)

2.426.1

Anything else is rejected (a non-numeric component gives in version '<v>', component '<c>' is not a valid integer, and any other count gives version <v> contains <n> component(s) which doesn’t correspond to any valid release type).

This is what makes the condition useful: it does not merely check that a version was published, it checks that you are not about to install a weekly where you meant an LTS.

Example

In the following example we want to update a Jenkins Docker image tag inside a YAML file each time a new Jenkins weekly release is published, but only after validating that:

  1. a matching Docker image has been published;

  2. the infrastructure uses the expected image name;

  3. the version really is a weekly release.

updatecli apply --config updatecli.yaml --values values.yaml
# updatecli.yaml
name: Example with Jenkins resource

scms:
  default:
    kind: git
    spec:
      url: "git@github.com:alice/example.git"
      branch: master
      user: alice
      email: alice@example.com

sources:
  lastWeeklyRelease:
    # Get latest jenkins weekly version with changelog from github
    kind: jenkins
    spec:
      release: weekly

conditions:
  # Test that a specific Jenkins version exists
  jenkinsVersion:
    kind: jenkins
    spec:
      version: "2.275"

  # Test that the version from source is a weekly release
  jenkinsWeekly:
    kind: jenkins
    spec:
      release: weekly

  # Test that our yaml file is correctly set to a jenkins image
  imageTag:
    name: "jenkins/jenkins docker image set"
    kind: yaml
    spec:
      file: "charts/jenkins/values.yaml"
      key: "jenkins.controller.image"
      value: "jenkins/jenkins"
    scmid: default

  # Test that there is a docker image with the correct tag
  # set to "<version>-jdk11"
  dockerimage:
    kind: dockerimage
    spec:
      image: jenkins/jenkins
    transformers:
      - addsuffix: "-jdk11"

targets:
  imageTag:
    name: "jenkins/jenkins docker tag"
    kind: yaml
    spec:
      file: "charts/jenkins/values.yaml"
      key: "jenkins.controller.tag"
    transformers:
      - addsuffix: "-jdk11"
    scmid: default
# values.yaml
---
github:
  token: ENVIRONMENT_VARIABLE_NAME
  username: alice