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 | “artifactid” defines the Maven artifact artifactId. compatible:
example:
| |
| groupid | string | “groupid” defines the Maven artifact groupId. compatible:
example:
| |
| repositories | array | “repositories” defines the list of Maven repositories where to look for versions. compatible:
default: Maven Central remark:
example:
| |
| repository | string | “repository” defines the Maven repository url, including the repository name. compatible:
remark:
example:
| |
| url | string | “url” defines the Maven repository base url. compatible:
deprecated:
| |
| version | string | “version” defines the Maven artifact version to check. compatible:
default: the output of the associated source. | |
| versionfilter | object | “versionfilter” defines the version pattern and its kind, such as “regex”, “semver” or “latest”. compatible:
| |
| kind | string | “kind” defines the versioning scheme used to select a version. default: latest remark:
example:
| |
| pattern | string | “pattern” defines the version pattern, according to “kind”. default:
remark:
example:
| |
| regex | string | “regex” defines the regular expression extracting the version from each entry. remark:
example:
| |
| replaceall | object | “replaceall” applies a regular expression replacement to each version before filtering. remark:
example: turns “curl-8_15_0” into “curl-8.15.0”. | |
| strict | boolean | “strict” enforces strict semantic versioning rules when parsing versions. default: false remark:
|
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 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-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.