Git Tag
kind: gittag
On this page
source | condition | target |
---|---|---|
✔ | ✔ | ✔ |
source
The Git Tag "source" retrieves the latest git Tag matching a pattern.
condition
The Git Tag "condition" tests if git Tag matching a pattern exist.
target
The Git Tag "target" ensures a git Tag matching a pattern exist otherwise it creates it.
Parameter
The gittag resource is a resource designed to be used with the scmID
Name | Type | Description | Required |
---|---|---|---|
key | string | “key” of the tag object to retrieve. Accepted values: [’name’,‘hash’]. Default: ’name’ Compatible:
| |
message | string | Message associated to the git tag compatible:
| |
password | string | “password” specifies the password when using the HTTP protocol
| |
path | string | Path contains the git repository path | |
sourcebranch | string | “sourcebranch” defines the branch name used as a source to create the new Git branch. compatible:
remark:
| |
url | string | “url” specifies the git url to use for fetching Git Tags.
| |
username | string | “username” specifies the username when using the HTTP protocol
| |
versionfilter | object | VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest. compatible:
| |
kind | string | specifies the version kind such as semver, regex, or latest | |
pattern | string | specifies the version pattern according the version kind | |
strict | boolean | strict enforce strict versioning rule. Only used for semantic versioning at this time |
Example
# updatecli.yaml
---
name: "Test new gittag resource"
scms:
gitExample:
kind: "git"
spec:
url: "git@github.com:updatecli/updatecli.git"
branch: "main"
githubExample:
kind: "github"
spec:
user: "updatecli-bot"
email: "updatecli@example.com"
owner: "updatecli"
repository: "updatecli"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: "john"
branch: "main"
sources:
gitExample1:
name: "Get Latest updatecli test"
kind: gittag
scmid: gitExample
spec:
path: "./git_repository_path/"
gitExample2: # Without scmid
name: Get Latest updatecli test
kind: gittag
spec:
path: "./git_repository_path/"
githubSemver:
name: Get Latest updatecli test
kind: gittag
scmid: githubExample
spec:
versionfilter:
kind: semver
pattern: "~0.1"
githubRegex:
name: Get Latest updatecli test
kind: gittag
scmid: githubExample
spec:
versionfilter:
kind: regex
pattern: "v0.*"
conditions:
gitRegex:
name: Test Get Latest updatecli test
disablesourceinput: true
kind: gittag
scmid: gitExample
spec:
versionfilter:
pattern: "v0.1.2"
targets:
github:
sourceid: githubRegex
name: Publish tag with -github
scmid: githubExample
kind: gittag
transformers:
- addsuffix: "-github"
git:
scmid: gitExample
sourceid: githubRegex
name: Publish tag with -git
kind: gittag
transformers:
- addsuffix: "-git"
VersionFilter
versionFilter
allows to specify the kind of version retrieved from a resource and its version pattern.
Default value is "latest" as we want to retrieve the newest version from a resource.
latest
If kind is set to latest
then no need to specify the patter as we gonna retrieve the newest version from the resource.
sources:
kubectl:
kind: githubRelease
spec:
owner: "kubernetes"
repository: "kubectl"
token: "{{ requiredEnv .github.token }}"
username: "john"
versionFilter:
kind: latest
transformers:
- trimPrefix: "kubernetes-"
Return the latest Github release and remove "kubernetes-" from it.
regex
If versionFilter.kind
is set to regex
then we can use versionFilter.pattern
to specify a regular expression to
return the newest version returned from a resource matching the regex
If no versionFilter.pattern is provided then it uses '.*' which return the newest version
sources:
kubectl:
kind: githubRelease
spec:
owner: "kubernetes"
repository: "kubectl"
token: "{{ requiredEnv .github.token }}"
username: "john"
versionFilter:
kind: regex
pattern: "kubernetes-1.(\d*).(\d*)$"
transformers:
- trimPrefix: "kubernetes-"
⇒ Return the newest kubectl version matching pattern "kubernetes-1.(\d*).(\d*)$" and remove "kubernetes-" from it
semver
If versionFilter.kind
is set to semver
then we can use versionFilter.pattern
to specify version pattern as explained here. In the process we also sort.
If no versionFilter.pattern
is provided then it fallback to '*' which return the newest version.
If a version doesn’t respect semantic versioning, then it’s not the value is just ignored.
Remark
In the process we drop any characters not respecting semantic version like in this version "v1.0.0", we drop the "v" but we can added it back using transformers
.
jenkins-wiki-exporter:
kind: githubRelease
spec:
owner: "jenkins-infra"
repository: "jenkins-wiki-exporter"
token: "{{ requiredEnv .github.token }}"
username: "john"
versionFilter:
kind: semver
pattern: "~1.10"
⇒ Return the version "v1.10.3"