On this page
Maven Repository
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
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
versionexists for the artifact.- target
Not supported - a target fails with
Target not supported for the plugin Maven. To write a version into apom.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
| Name | Type | Description | Required |
|---|---|---|---|
| artifactid | string | Specifies the maven artifact artifactID | |
| groupid | string | Specifies the maven artifact groupID | |
| repositories | array | Repositories 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. | |
| repository | string | Specifies the maven repository url + name | |
| url | string | Deprecated, please specify the Maven url in the repository | |
| version | string | Specifies the maven artifact version | |
| versionfilter | object | [S] VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest. | |
| kind | string | specifies the version kind such as semver, regex, or latest | |
| pattern | string | specifies 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 | |
| regex | string | specifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used. | |
| replaceall | object | replaceAll 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. | |
| strict | boolean | strict 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 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-warNote | 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-warfrom the grouporg.jenkins-ci.mainin thereleasesrepository onrepo.jenkins-ci.org(2.264), then appendjdk11, giving2.264-jdk11.- Conditions
Check that a Docker image
jenkins/jenkins:2.264-jdk11is published on DockerHub, and that the keyjenkins.master.imageincharts/jenkins/values.yamlis set tojenkins/jenkins. Either failing stops the pipeline.- Targets
Update
jenkins.master.imageTagto2.264-jdk11in that file and commit the change.