Skip to content

Commit d663472

Browse files
committed
feature: add after_script support
Signed-off-by: Maximilian Bösing <[email protected]>
1 parent c2d713a commit d663472

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ The JSON string should represent an object with the following information:
3939
"command": "command to run to perform the check (empty in case you dont want to excecute any command)",
4040
"additional_composer_arguments": [
4141
"arguments which will be passed to `composer install` or `composer update`, passed as a list or as a list; e.g. --no-scripts"
42+
],
43+
"after_script": [
44+
"post process tool result"
4245
]
4346
}
4447
```
@@ -120,6 +123,9 @@ The `.laminas-ci/post-run.sh` command will receive these arguments:
120123
- `$3`: the WORKDIR path
121124
- `$4`: the `$JOB` passed to the entrypoint (see above)
122125

126+
It is also possible to pass `after_script` with a list of commands via the `$JOB` variable.
127+
`$STATUS` is a variable containing the exit code of the command and can be used in the commands listed in `after_script`.
128+
123129
#### Parsing the $JOB
124130

125131
You may want to grab elements of the `$JOB` argument in order to branch logic.

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function help {
1414
echo " - dependencies: the dependency set to run against (lowest, latest, locked)"
1515
echo " - ignore_php_platform_requirement: flag to enable/disable the PHP platform requirement when executing composer \`install\` or \`update\`"
1616
echo " - additional_composer_arguments: a list of composer arguments to be added when \`install\` or \`update\` is called."
17+
echo " - after_script: a list of commands to run after the real command"
1718
echo ""
1819
}
1920

@@ -138,6 +139,9 @@ if [[ "${PHP}" == "" ]];then
138139
exit 1
139140
fi
140141

142+
declare -a AFTER_SCRIPT=()
143+
readarray -t AFTER_SCRIPT="$(echo "${JOB}" | jq -rc '(.after_script // [])[]' )"
144+
141145
echo "Marking PHP ${PHP} as configured default"
142146
update-alternatives --quiet --set php "/usr/bin/php${PHP}"
143147
update-alternatives --quiet --set php-config "/usr/bin/php-config${PHP}"
@@ -231,4 +235,9 @@ if [ -x ".laminas-ci/post-run.sh" ];then
231235
./.laminas-ci/post-run.sh "${STATUS}" testuser "${PWD}" "${JOB}"
232236
fi
233237

238+
for AFTER_SCRIPT_COMMAND in "${AFTER_SCRIPT[@]}"; do
239+
echo "Running before_script: ${AFTER_SCRIPT_COMMAND}"
240+
sudo --preserve-env --set-home -u testuser /bin/bash -c "${AFTER_SCRIPT_COMMAND}"
241+
done
242+
234243
exit ${STATUS}

0 commit comments

Comments
 (0)