sourceconditiontarget

Description

The maven resource reads the maven-metadata.xml of an artifact and returns a version from it.

source

Returns the version matching versionfilter.

condition

Checks that version exists for the artifact.

target

Not supported - a target fails with Target not supported for the plugin Maven. To write a version into a pom.xml, use the "XML" resource, or the maven autodiscovery crawler.

Note
An scm attached to a condition is not supported and aborts it with SCM configuration is not supported for maven condition, aborting.

Parameters

NameTypeDescriptionRequired
artifactidstringSpecifies the maven artifact artifactID
groupidstringSpecifies the maven artifact groupID
repositoriesarrayRepositories specifies a list of Maven repository where to look for version. Order matter, version is retrieve from the first repository with the last one being Maven Central.
repositorystringSpecifies the maven repository url + name
urlstringDeprecated, please specify the Maven url in the repository
versionstringSpecifies the maven artifact version
versionfilterobject[S] VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.
    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format
    regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
    replaceallobjectreplaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction.
    strictbooleanstrict enforce strict versioning rule. Only used for semantic versioning at this time

groupid and artifactid identify the artifact; the group’s dots become path separators when the metadata URL is built. version is condition-only.

repository and repositories are mutually exclusive (setting both is rejected with parameter "repository" and "repositories" are mutually exclusive).

Note
url is deprecated. It is prepended to repository and logs Parameter "URL" is deprecate, please prefix its content to parameter "repository". Put the whole URL in repository instead.

Repositories

Important

Maven Central is always consulted. Unless https://repo.maven.apache.org/maven2 already appears in repositories, Updatecli appends it as the last repository to try.

A lookup against a private repository therefore falls through to Maven Central rather than failing when the artifact is missing (which is convenient for public dependencies, and surprising if you expected an internal-only artifact to be resolved internally or not at all).

repositories is ordered: the first repository that answers wins, with Maven Central last. Use it when an artifact may live in either a snapshot or a release repository:

spec:
  repositories:
    - https://repo.jenkins-ci.org/releases
    - https://repo.jenkins-ci.org/public
  groupid: org.jenkins-ci.main
  artifactid: jenkins-war
Note
repository can carry Basic Auth credentials in the standard notation, username:password@hostname. Use templating to keep the password out of the manifest.

Example

# updatecli.yaml
name: Example with Maven resource

scms:
  default:
    kind: git
    spec:
      url: "git@github.com:olblak/charts.git"
      branch: master
      user: olblak
      email: me@olblak.com
      directory: "/home/olblak/Project/Jenkins-infra/charts"

sources:
  default:
    kind: maven
    spec:
      # optionally provide credentials as user:pass@hostname
      # using requiredEnv custom function
      repository: "repo.jenkins-ci.org/releases"
      groupid: "org.jenkins-ci.main"
      artifactid: "jenkins-war"
    transformers:
      - addsuffix: "-jdk11"

conditions:
  docker:
    name: "Test Docker Image Published on Registry with the correct tag"
    kind: "dockerimage"
    spec:
      image: "jenkins/jenkins"
  imageTag:
    name: "Test if jenkins/jenkins docker image used"
    scmid: default
    kind: yaml
    spec:
      file: "charts/jenkins/values.yaml"
      key: "jenkins.master.image"
      value: "jenkins/jenkins"

targets:
  imageTag:
    name: "jenkins/jenkins docker tag"
    kind: yaml
    scmid: default
    spec:
      file: "charts/jenkins/values.yaml"
      key: "jenkins.master.imageTag"

What it says:

Sources

Retrieve the version of the artifact jenkins-war from the group org.jenkins-ci.main in the releases repository on repo.jenkins-ci.org (2.264), then append jdk11, giving 2.264-jdk11.

Conditions

Check that a Docker image jenkins/jenkins:2.264-jdk11 is published on DockerHub, and that the key jenkins.master.image in charts/jenkins/values.yaml is set to jenkins/jenkins. Either failing stops the pipeline.

Targets

Update jenkins.master.imageTag to 2.264-jdk11 in that file and commit the change.