check: add source and target_branch to metadata file
User might want to read the target_branch from concourse. This adds the target_branch field to the metadafile file in order to read it from Concourse side
For context I'm using this with the accross hack to do some Linux kernel build depending on the kernel version:
- name: merge-request-build
public: true
plan:
- in_parallel:
- get: merge-request
params:
skip_clone: true
- load_var: merge-request-info
file: merge-request/.merge-request.json
format: json
- task: check_version
config:
platform: linux
image_resource:
type: registry-image
source:
repository: busybox
inputs:
- name: merge-request
outputs:
- name: version
run:
path: sh
args:
- -exc
- |
cat merge-request/.merge-request.json
if [ "((.:merge-request-info.target_branch))" == "5.15" ]; then
echo ["5.15"] > version/5.15
echo [] > version/6.12
echo "It's a 5.15 kernel"
else if [ "((.:merge-request-info.target_branch))" == "6.12" ]
echo [] > version/5.15
echo ["6.12"] > version/6.12
echo "It's a 6.12 kernel"
else
echo [] > version/5.15
echo [] > version/6.12
echo "Not a known kernel"
fi
- load_var: is_515
file: version/5.15
format: json
- across:
- var: version
values: ((.:is_515))
do:
- in_parallel:
# HACK:
# Put step call an implicit get step. Since skip_clone is not kept between
# get call, use the put to actually clone the repo. This way we can
# dispatch to the correct "accros" quickly
- put: merge-request
params:
resource_name: merge-request
status: pending
- task: build_5_15_kernel
<...>
- load_var: is_612
file: version/6.12
format: json
- across:
- var: version
values: ((.:is_612))
do:
- in_parallel:
# HACK:
# Put step call an implicit get step. Since skip_clone is not kept between
# get call, use the put to actually clone the repo. This way we can
# dispatch to the correct "accros" quickly
- put: merge-request
params:
resource_name: merge-request
status: pending
- task: build_6_12_kernel
<...>
Edited by Esteban Blanc