Skip to content

Commit

Permalink
Pass thru params (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
roopakv authored Mar 28, 2021
1 parent 5b725ee commit ac363d6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/commands/filter-and-continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ parameters:
default: ".circleci/continue_config.yml"
description: >
The location of the config to continue the pipeline with.
additional-param-map:
description: |
Any additional params that should be sent to the continue config. Pass in empty
json object `{}` if you have nothing specific to override.
Input should be json, something like '{"run_trigger_workflow": false}'
type: string
default: '{}'
pass-only-additional-params-thru:
description: |
If you are trying to run some jobs on your continue config but not look at what changed,
set this to true and pass the jobs you want ot run. This sets the additional params and ignores
everything from the code-param-name-map.
type: boolean
default: false
steps:
- run:
name: Swissknife - Set Parameters and continue
Expand All @@ -74,6 +89,7 @@ steps:
# Validate input JSON.
echo "Validating input JSON";
echo '<< parameters.code-param-name-map >>' | jq type || { echo "Invalid input map JSON"; exit 1; }
echo '<< parameters.additional-param-map >>' | jq type || { echo "Invalid additional param map JSON"; exit 1; }
append_string_to_params() {
current_data=`cat /tmp/swissknife/workflow_params.json`
Expand All @@ -83,6 +99,7 @@ steps:
mkdir -p /tmp/swissknife
touch /tmp/swissknife/workflow_params.json
echo '{}' | jq -j . > /tmp/swissknife/workflow_params.json
echo '<< parameters.additional-param-map >>' | jq -j . > /tmp/swissknife/additional_params.json
FILES_MODIFIED=""
get_modified_files_for_regex() {
Expand Down Expand Up @@ -164,18 +181,38 @@ steps:
done
}
combine_params() {
echo "workflow params"
cat /tmp/swissknife/workflow_params.json
echo ""
echo "additional params"
cat /tmp/swissknife/additional_params.json
echo ""
if [[ "<< parameters.pass-only-additional-params-thru >>" == "false" ]]; then
jq -j -n --argfile o1 /tmp/swissknife/workflow_params.json --argfile o2 /tmp/swissknife/additional_params.json '$o1 * $o2' > /tmp/swissknife/final_params.json
else
echo "Passing thru only additional params"
cp /tmp/swissknife/additional_params.json /tmp/swissknife/final_params.json
fi
echo ""
echo "final params"
cat /tmp/swissknife/final_params.json
}
if [ "$CIRCLE_BRANCH" == "<< parameters.base-branch >>" ]; then
if [[ "run_all" == "<< parameters.run-mode-for-base-branch >>" ]]; then
generate_all_params
else
generate_branch_params
fi
combine_params
exit 0;
fi
echo "Non base branch";
generate_branch_params
combine_params
- continuation/continue:
configuration_path: << parameters.config-path >>
parameters: "/tmp/swissknife/workflow_params.json"
parameters: "/tmp/swissknife/final_params.json"

17 changes: 17 additions & 0 deletions src/jobs/filter-and-continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ parameters:
default: ".circleci/continue_config.yml"
description: >
The location of the config to continue the pipeline with.
additional-param-map:
description: |
Any additional params that should be sent to the continue config. Pass in empty
json object `{}` if you have nothing specific to override.
Input should be json, something like '{"run_trigger_workflow": false}'
type: string
default: '{}'
pass-only-additional-params-thru:
description: |
If you are trying to run some jobs on your continue config but not look at what changed,
set this to true and pass the jobs you want ot run. This sets the additional params and ignores
everything from the code-param-name-map.
type: boolean
default: false
steps:
- checkout
- filter-and-continue:
Expand All @@ -66,3 +81,5 @@ steps:
code-param-name-map: << parameters.code-param-name-map >>
search-mode: << parameters.search-mode >>
config-path: << parameters.config-path >>
additional-param-map: << parameters.additional-param-map >>
pass-only-additional-params-thru: << parameters.pass-only-additional-params-thru >>

0 comments on commit ac363d6

Please sign in to comment.