From d2f1785f51e614b767d3365589c407e424ee48f3 Mon Sep 17 00:00:00 2001 From: quebim Date: Tue, 29 Oct 2024 13:51:26 -0300 Subject: [PATCH] Add commit hashes as parameters to the baptizer scriot Update build workflow to call baptizer passing the new parameters --- .github/workflows/build.yml | 4 ++-- build-scripts/baptizer.sh | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56d816394385a..e55f0d3c9f8f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -253,12 +253,12 @@ jobs: - name: Run `baptizer.sh` # As parameters run: | - PLUGINS_HASH=${{ needs.build-wazuh-plugins.outputs.hash }} \ - REPORTING_HASH=${{ needs.build-reporting-plugin.outputs.hash }} \ name=$(bash build-scripts/baptizer.sh \ -a ${{ matrix.architecture }} \ -d ${{ matrix.distribution }} \ -r ${{ inputs.revision }} \ + -ph ${{ needs.build-wazuh-plugins.outputs.hash }} \ + -rh ${{ needs.build-reporting-plugin.outputs.hash }} \ ${{ inputs.is_stage && '-x' || '' }} \ ) echo "name=$name" >> $GITHUB_OUTPUT diff --git a/build-scripts/baptizer.sh b/build-scripts/baptizer.sh index d892231ae51fa..5a9effc11dae2 100644 --- a/build-scripts/baptizer.sh +++ b/build-scripts/baptizer.sh @@ -12,6 +12,8 @@ function usage() { echo -e "-r REVISION\t[Optional] Package revision, default is '0'." echo -e "-m MIN\t[Optional] Use naming convention for minimal packages, default is 'false'." echo -e "-x RELEASE\t[Optional] Use release naming convention, default is 'false'." + echo -e "-ph PLUGINS_HASH\t[Optional] Commit hash from the wazuh-indexer-plugins repository" + echo -e "-rh REPORTING_HASH\t[Optional] Commit hash from the wazuh-indexer-reporting repository" echo -e "-h help" } @@ -20,7 +22,7 @@ function usage() { # ==== function parse_args() { - while getopts ":h:p:a:d:r:mx" arg; do + while getopts ":h:p:a:d:r:m:x:ph:rh" arg; do case $arg in h) usage @@ -44,6 +46,12 @@ function parse_args() { x) IS_RELEASE=true ;; + ph) + PLUGINS_HASH=$OPTARF + ;; + rh) + REPORTING_HASH=$OPTARF + ;; :) echo "Error: -${OPTARG} requires an argument" usage @@ -129,7 +137,7 @@ function get_devel_name() { PREFIX="$PREFIX"-min fi # Generate composed commit hash - if "$PLUGINS_HASH" && "$REPORTING_HASH"; then + if [ -n "$PLUGINS_HASH" ] && [ -n "$REPORTING_HASH" ]; then COMMIT_HASH="$GIT_COMMIT"-"$PLUGINS_HASH"-"$REPORTING_HASH" fi PACKAGE_NAME="$PREFIX"_"$VERSION"-"$REVISION"_"$SUFFIX"_"$COMMIT_HASH"."$EXT"