sourceconditiontarget

✔

✔

✗

Description

The gitlab/tag resource queries the tags of a repository hosted on GitLab, through the GitLab API rather than over the git protocol.

source

Returns the tag matching versionfilter.

condition

Tests that tag exists in the repository.

target

Not supported - a target fails with target not supported for the plugin GitLab Tags. Say so on the issue tracker if you would use one.

Note
An scm attached to a condition is ignored, with a warning. The lookup always goes to the GitLab API.
Tip
To work with tags over the git protocol instead, on any host (and to create one), use gittag.

Parameters

NameTypeDescriptionRequired
ageobject

“age” defines the minimum or maximum age of a tag to be considered valid.

compatible:

  • source

remark:

  • it accepts a duration string such as “24h”, “7d”, “3w” or “1y”.
  • the age of a tag is its creation date, which GitLab reports as the tagger date of an annotated tag and as the commit date of a lightweight one.
  • when no tag matches the age filter yet, the source is skipped instead of failing.
    maximumstring

“maximum” defines the maximum age a release may have to be considered.

remark:

  • accepted units are “d” for days, “w” for weeks, “mo” for months and “y” for years, plus the Go duration units such as “h”, “m” and “s”.
  • a unit is required.
  • a month counts as 1/12 of a year and a year as 365 days.

example:

  • maximum: 6mo
  • maximum: 1y
    minimumstring

“minimum” defines the minimum age a release must have to be considered.

remark:

  • accepted units are “d” for days, “w” for weeks, “mo” for months and “y” for years, plus the Go duration units such as “h”, “m” and “s”.
  • a unit is required.
  • a month counts as 1/12 of a year and a year as 365 days.

example:

  • minimum: 24h
  • minimum: 7d
  • minimum: 3w
ownerstring

“owner” defines the owner of the GitLab repository.

compatible:

  • source
  • condition

example:

  • owner: updatecli
repositorystring

“repository” defines the name of the GitLab repository, for a specific owner.

compatible:

  • source
  • condition

example:

  • repository: updatecli
tagstring

“tag” defines the name of the tag to look for.

compatible:

  • condition

default: the output of the associated source.

example:

  • tag: v1.0.0
tokenstring

“token” defines the credential used to authenticate with GitLab.

remark:

  • a token is sensitive information. Do not set it directly in the manifest, use an environment variable or a SOPS file instead.
  • {{ requiredEnv "GITLAB_TOKEN" }} retrieves the token from the environment variable GITLAB_TOKEN.
  • {{ .gitlab.token }} retrieves the token from a SOPS file.
  • for more information about SOPS files, see https://github.com/getsops/sops

example:

  • token: ‘{{ requiredEnv “GITLAB_TOKEN” }}’
urlstring

“url” defines the GitLab url to interact with.

default: gitlab.com

remark:

  • “https://” is added when the url has no “http://” or “https://” scheme.

example:

  • url: gitlab.com
  • url: https://gitlab.example.com
usernamestring“username” defines the username used to authenticate with GitLab.
versionfilterobject

“versionfilter” defines the version pattern and kind used to select the tag, such as regex, semver or latest.

compatible:

  • source

default: kind: latest

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

owner and repository are mandatory. url defaults to gitlab.com. Set it for a self-managed instance.

tag

Condition only - the tag being checked.

versionfilter

Source only. kind: semver is the usual choice for release tags. See the "Version Filtering" page.

Authentication

token authenticates against the GitLab API. It is sensitive, so read it from the environment or a SOPS file rather than writing it into the manifest:

spec:
  url: gitlab.com
  token: '{{ requiredEnv "GITLAB_TOKEN" }}'
  owner: updatecli
  repository: updatecli

Reading a public repository works without any credential.

Example

# updatecli.yaml
name: "Show Gitlab tag usage"

sources:
  default:
    name: "Get tag using versionfilter from a Gitlab repository"
    kind: "gitlab/tag"
    spec:
      # Default to gitlab.com
      # url: "gitlab.com"
      owner: "olblak"
      repository: "updatecli-test"
      versionfilter:
        kind: "semver"
        pattern: "~0.0"

  latest:
    name: "Get latest tag tag from a Gitlab repository"
    kind: "gitlab/tag"
    spec:
      # Default to gitlab.com
      # url: "gitlab.com"
      owner: "olblak"
      repository: "updatecli-test"

conditions:
  default:
    name: "Test tag '0.0.2' exist on the Gitlab repository"
    kind: "gitlab/tag"
    disablesourceinput: true
    spec:
      # Default to gitlab.com
      # url: "gitlab.com"
      owner: "olblak"
      repository: "updatecli"
      tag: "v0.2.0"

  sourcedefault:
    name: "Test that the tag retrieved from source 'default' exist on the Gitlab repository"
    kind: "gitlab/tag"
    sourceid: "default"
    spec:
      # Default to gitlab.com
      # url: "gitlab.com"
      owner: "olblak"
      repository: "updatecli"

  latest:
    name: "Test that the tag retrieved from source 'latest' exist on the Gitlab repository"
    kind: "gitlab/tag"
    sourceid: "latest"
    spec:
      # Default to gitlab.com
      # url: "gitlab.com"
      owner: "olblak"
      repository: "updatecli"