JSON

kind: json

sourceconditiontarget

Description

source

The JSON "source" retrieves an information from a JSON file.

condition

The JSON "condition" tests that an information exist in a JSON file.

target

The JSON "target" ensures that a JSON file content a specific value at specific location.

Parameters

NameTypeDescriptionRequired
enginestring

default:

  • “dasel/v1” is the default engine used to manipulate json files

accepted values:

  • “dasel/v1” for dasel v1 engine
  • “dasel/v2” for dasel v2 engine
  • “dasel” for the latest dasel engine which is currently dasel v2
filestring

remark:

  • “file” and “files” are mutually exclusive
  • scheme “https://”, “http://”, and “file://” are supported in path for source and condition
filesarray

remark:

  • “file” and “files” are mutually exclusive
  • scheme “https://”, “http://”, and “file://” are supported in path for source and condition
keystring

key defines the Jsonpath key to manipulate.

compatible:

  • source
    • condition
    • target

remark: * key is a simpler version of Jsonpath accepts keys. * key accepts Dasel query, more information on https://github.com/tomwright/dasel

  • key accepts values based on the engine used

example: * key: $.name * key: name * file: https://nodejs.org/dist/index.json key: .(lts!=false).version

querystring

query defines the Jsonpath query to manipulate. It accepts advanced Dasel v1 query this parameter is now deprecated in Dasel v2 and replaced by the parameter “key”.

compatible: * source * condition * target

example: * query: .name * query: “.[*].tag_name”

remark: * query accepts Dasel query, more information on https://github.com/tomwright/dasel

valuestring

value defines the Jsonpath key value to manipulate. Default to source output.

compatible:

  • condition
    • target

default: when used for a condition or a target, the default value is the output of the source.

versionfilterobject
kindstringspecifies the version kind such as semver, regex, or latest
patternstringspecifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format
regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
replaceallobjectreplaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction.
strictbooleanstrict enforce strict versioning rule. Only used for semantic versioning at this time

Query

The JSON plugin relies on Dasel to query json files

Examples

Retrieves a value from a JSON file

# updatecli.yaml
name: Basic Json Example
scms:
 default:
 kind: git
 spec:
 url: https://github.com/updatecli/updatecli.git
sources:
 local:
 name: Get value from json
 kind: json
 scmid: default
 spec:
 file: pkg/plugins/resources/json/testdata/data.json
 key: firstName
 http:
 name: Get value from json
 kind: json
 spec:
 file: https://www.updatecli.io/schema/latest/config.json
 key: $id
conditions:
 local:
 name: Test value from json
 kind: json
 sourceid: local
 scmid: default
 spec:
 file: pkg/plugins/resources/json/testdata/data.json
 key: firstName
 http:
 name: Test value from json
 kind: json
 disablesourceinput: true
 spec:
 file: https://www.updatecli.io/schema/latest/config.json
 key: $schema
 value: http://json-schema.org/draft-04/schema
targets:
 local:
 name: Test value from json
 kind: json
 sourceid: local
 scmid: default
 spec:
 file: pkg/plugins/resources/json/testdata/data.json
 key: firstName
 value: John

Uses a path to find a value in a JSON file

# jenkins-old-versions.yaml
# We're working with https://updates.jenkins.io/tiers.json
# {"stableCores":["2.346.3","2.361.1", ...,"2.414.2"],"weeklyCores":["2.364","2.371",...,"2.425"]}
# This example finds the oldest weekly and stable supported Jenkins versions (first in the list)
# It also finds the latest weekly and stable Jenkins versions (last in the list)
name: Find oldest supported Jenkins versions
scms:
 default:
 kind: github
 spec:
 user: "{{ .github.user }}"
 email: "{{ .github.email }}"
 owner: "{{ .github.owner }}"
 repository: "{{ .github.repository }}"
 token: "{{ requiredEnv .github.token }}"
 username: "{{ .github.username }}"
 branch: "{{ .github.branch }}"
sources:
 JenkinsOldestSupportedWeekly:
 name: Get the oldest supported Jenkins weekly version
 kind: json
 scmid: default
 spec:
 file: https://updates.jenkins.io/tiers.json
 key: "weeklyCores.[0]"
 JenkinsOldestSupportedStable:
 name: Get the oldest supported Jenkins stable version
 kind: json
 scmid: default
 spec:
 file: https://updates.jenkins.io/tiers.json
 # `key` targets only one value, the first one of the list in this case
 key: "stableCores.[0]"
 JenkinsNewestWeeklyVersion:
 name: Get the newest supported Jenkins weekly version
 kind: json
 spec:
 file: https://updates.jenkins.io/tiers.json
 # Here we use `query` to target all the values in the list
 query: "weeklyCores.[*]"
 # We use `versionfilter` to filter the list of versions
 # Combined with `semver`, we can target the latest version that follows the semver pattern
 versionfilter:
 kind: semver
 JenkinsNewestStableVersion:
 name: Get the newest supported Jenkins stable version
 kind: json
 spec:
 file: https://updates.jenkins.io/tiers.json
 query: "stableCores.[*]"
 versionfilter:
 kind: semver
conditions:
 # Test that the oldest Jenkins supported weekly version exists
 jenkinsOldestSupportedWeeklyVersion:
 kind: jenkins
 spec:
 release: weekly
 sourceid: JenkinsOldestSupportedWeekly
 # Test that the oldest Jenkins supported stable version exists
 jenkinsOldestSupportedStableVersion:
 kind: jenkins
 sourceid: JenkinsOldestSupportedStable
 # Test that the newest Jenkins supported weekly version exists
 jenkinsNewestSupportedWeeklyVersion:
 kind: jenkins
 spec:
 release: weekly
 sourceid: JenkinsNewestWeeklyVersion
 # Test that the newest Jenkins supported stable version exists
 jenkinsNewestSupportedStableVersion:
 kind: jenkins
 sourceid: JenkinsNewestStableVersion
targets:
 setJenkinsOldestSupportedWeekly:
 kind: file
 name: "Bump Jenkins oldest weekly supported version in the \"Choosing a version\" page"
 sourceid: JenkinsOldestSupportedWeekly
 spec:
 file: content/doc/developer/plugin-development/choosing-jenkins-baseline.adoc
 matchpattern: >-
 (.*Do not use versions no longer supported by the update center.*older than )(.*)( for weekly releases.*for LTS releases.*)
 replacepattern: >-
 ${1}{{ source "JenkinsOldestSupportedWeekly" }}${3}
 scmid: default
 setJenkinsOldestSupportedStable:
 kind: file
 name: "Bump Jenkins oldest stable supported version in the \"Choosing a version\" page"
 sourceid: JenkinsOldestSupportedStable
 spec:
 file: content/doc/developer/plugin-development/choosing-jenkins-baseline.adoc
 matchpattern: >-
 (.*Do not use versions no longer supported by the update center.* weekly releases, and )(.*)( for LTS releases.*)
 replacepattern: >-
 ${1}{{ source "JenkinsOldestSupportedStable" }}${3}
 scmid: default
actions:
 default:
 kind: github/pullrequest
 scmid: default
 title: Bump Jenkins LTS and weekly versions in various parts of the documentation
 spec:
 labels:
 - dependencies
 - chore
Top

AltStyle によって変換されたページ (->オリジナル) /