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
artifactidstring

“artifactid” defines the Maven artifact artifactId.

compatible:

  • source
  • condition

example:

  • artifactid: jenkins-war
groupidstring

“groupid” defines the Maven artifact groupId.

compatible:

  • source
  • condition

example:

  • groupid: org.jenkins-ci.main
repositoriesarray

“repositories” defines the list of Maven repositories where to look for versions.

compatible:

  • source
  • condition

default: Maven Central

remark:

  • “repository” and “repositories” are mutually exclusive.
  • order matters: the version is retrieved from the first repository that returns one.
  • Maven Central is added as the last repository unless the list already holds it.
  • “https://” is added when a url has no scheme.

example:

  • repositories:
    • https://repo.jenkins-ci.org/releases
    • https://repo1.maven.org/maven2
repositorystring

“repository” defines the Maven repository url, including the repository name.

compatible:

  • source
  • condition

remark:

  • “repository” and “repositories” are mutually exclusive. When both are set, “repositories” is ignored.
  • “https://” is added when the url has no scheme.
  • Maven Central is not queried when “repository” is set.

example:

  • repository: https://repo.jenkins-ci.org/releases
urlstring

“url” defines the Maven repository base url.

compatible:

  • source
  • condition

deprecated:

  • set the full url in “repository” instead. “url” is prefixed to “repository”.
versionstring

“version” defines the Maven artifact version to check.

compatible:

  • condition

default: the output of the associated source.

versionfilterobject

“versionfilter” defines the version pattern and its kind, such as “regex”, “semver” or “latest”.

compatible:

  • source
    kindstring

“kind” defines the versioning scheme used to select a version.

default: latest

remark:

  • accepted values are “latest”, “semver”, “regex”, “regex/semver”, “time”, “regex/time”, “lex” and “pep440”.
  • “latest” returns the last version of the list.
  • “lex” sorts the versions lexicographically and returns the last one.
  • “pep440” follows https://peps.python.org/pep-0440/

example:

  • kind: semver
    patternstring

“pattern” defines the version pattern, according to “kind”.

default:

  • latest: “latest”
  • semver and pep440: “*”
  • regex: “.*”
  • time and regex/time: “2006-01-02”

remark:

  • for “latest”, “latest” returns the last version, any other value must match a version exactly.
  • for “semver” and “regex/semver”, it is a semantic versioning constraint.
  • for “pep440”, it is a pep440 version specifier.
  • for “regex”, it is a regular expression.
  • for “time” and “regex/time”, it is a Go date layout.
  • ignored by “lex”.

example:

  • pattern: ~1.2
  • pattern: “>=1.0.0 <2.0.0”
  • pattern: ^v\d+.\d+.\d+$
    regexstring

“regex” defines the regular expression extracting the version from each entry.

remark:

  • only used by the kinds “regex/semver” and “regex/time”.
  • the value of the first capture group is used as the version.

example:

  • regex: ^v(\d+.\d+.\d+)$
    replaceallobject

“replaceall” applies a regular expression replacement to each version before filtering.

remark:

  • only used by the kinds “regex”, “regex/semver” and “regex/time”.
  • the replacement runs before “pattern” or “regex” is evaluated.

example:

replaceall:
  pattern: "_"
  replacement: "."

turns “curl-8_15_0” into “curl-8.15.0”.

    strictboolean

“strict” enforces strict semantic versioning rules when parsing versions.

default: false

remark:

  • only used by the kinds “semver” and “regex/semver”.

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 template functions 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.