Git Tag

kind: gittag

sourceconditiontarget

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

NameTypeDescriptionRequired
keystring

“key” of the tag object to retrieve.

Accepted values: [’name’,‘hash’].

Default: ’name’ Compatible:

  • source
messagestring

Message associated to the git tag

compatible:

  • target
passwordstring

“password” specifies the password when using the HTTP protocol

compatible:
  * source
  * condition
  * target
pathstringPath contains the git repository path
sourcebranchstring

“sourcebranch” defines the branch name used as a source to create the new Git branch.

compatible:

  • target

remark:

  • sourcebranch is required when the scmid is not defined.
urlstring

“url” specifies the git url to use for fetching Git Tags.

compatible:
  * source
  * condition
  * target

example:
  * git@github.com:updatecli/updatecli.git
  * https://github.com/updatecli/updatecli.git

remarks:
	when using the ssh protocol, the user must have the right to clone the repository
	based on its local ssh configuration
usernamestring

“username” specifies the username when using the HTTP protocol

compatible
  * source
  * condition
  * target
versionfilterobject

VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.

compatible:

  • source
  • condition
  • target
    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies the version pattern according the version kind
    strictbooleanstrict 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.

Example
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.

example
  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"

Top