Source

Source define the 'what' you want to update

Description

The "source" stage retrieves information from a third "resource" like a file, or an API and then uses that information in later stages.

Parameters

NameTypeDescriptionRequired
dependsonarray"dependson" allows to specify the order of execution of resources It accepts a list of rules like "(resourceType#)resourceId(:booleanOperator)" The resourceType is optional and can be one of "condition", "source" or "target" By default the resourceType is the current resource type The resourceId is the name of the resource to depend on The booleanOperator is optional and can be "AND" or "OR" examples: dependson: - condition#myCondition:and - source#mySource remarks: The parameters "sourceid" and "conditionsids" affect the order of resource execution. To avoid circular dependencies, the depended resource may need to remove any conditionids or set "disablesourceinput to true".
kindstringkind specifies the sources resource kind
namestringname specifies the resource name
scmidstringscmid specifies the scm configuration key associated to the current resource
specobjectspec specifies parameters for a specific sources kind
transformersarraytransformers defines how the default input value need to be transformed
    addprefixstringAddPrefix adds a prefix to the transformer input value
    addsuffixstringAddSuffix adds a suffix to the transformer input value
    findstringFind searches for a specific value if it exists and return false if it doesn't
    findsubmatchobjectFind searches for a specific value if it exists then return the value using regular expression[pattern]
    replacerobjectReplacer specifies what value needs to be changed and how[from to]
    replacersarrayReplacers specifies a list of replacer instruction
    semverincstringSemvVerInc specifies a comma separated list semantic versioning component that needs to be upgraded.
    trimprefixstringTrimPrefix removes a prefix to the transformer input value
    trimsuffixstringTrimSuffix removes the suffix from the transformer input value

Example

Transform source output

updatecli.yaml
sources:
  latestVersion:
    name: Get latest Venom release
    kind: githubRelease
    spec:
      owner: ovh
      repository: venom
      # Value from environment variable '$UPDATECLI_GITHUB_TOKEN'
      token: '{{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}'
      # Value from environment variable '$UPDATECLI_GITHUB_ACTOR'
      username: '{{ requiredEnv "UPDATECLI_GITHUB_ACTOR" }}'
      versioning:
        kind: semver
    transformers:
      - addPrefix: "v"

In this example we’re looking for the latest release tag from https://github.com/jenkinsci/jenkins which is 'jenkins-2.75'. Unfortunately, it contains the prefix "jenkins" which is not required for later stages, so we remove 'jenkins-' so the output of the source becomes "jenkins/jenkins:2.275-jdk" which is a valid docker image name This can now be used in the later stages.

Combine multiple sources

In Updatecli, sources define values (like version numbers) to use in your update logic.

You can combine outputs from multiple sources in a target, a condition, or even another source by using Go templating, like this:

sources:
  appVersion:
    kind: githubrelease
    spec:
      owner: myorg
      repository: myapp

  chartVersion:
    kind: helmchart
    spec:
      name: mychart

targets:
  updateChart:
    name: "Update Helm chart with app and chart versions"
    kind: file
    disablesourceinput: true
    spec:
      file: charts/myapp/Chart.yaml
      matchpattern: "version: .*"
      replacepattern: 'version: {{ source "chartVersion" }}'

Now, if you wanted to use both versions in one target, for example in a file or title, you can do something like this:

replacepattern: 'appVersion: {{ source "appVersion" }}, chartVersion: {{ source "chartVersion" }}'

Here are a few important concepts to understand: By default any condition or target inherites a source output, so we want to disable that behavior by setting disablesourceinput: true.

Combining multiple sources output is useful when:

Another resource needs information from more than one source, like updating multiple versions in the same file or message.

You want to compose a more informative or specific change, like:

image: 'myapp:{{ source "appVersion" }}-{{ source "buildNumber" }}'

PR titles like:

"chore: 'bump app to {{ source "appVersion" }} and chart to {{ source "chartVersion" }}"'
Top