From 7a2ec3c3ed67d3e33a4b50df69e621916f586f5f Mon Sep 17 00:00:00 2001 From: jeanjerome Date: Sat, 26 Aug 2023 00:42:22 +0200 Subject: [PATCH] ref(15): Start testing wild integration with Jenkins --- src/lib/workflow.sh | 64 ++++++++++++++++++++-------------------- vars/wildPipeline.groovy | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/lib/workflow.sh b/src/lib/workflow.sh index d3eb9f9..bd640e2 100644 --- a/src/lib/workflow.sh +++ b/src/lib/workflow.sh @@ -4,10 +4,10 @@ set -euo pipefail #@desc Check prerequisites for workflow. -#@ex workflow::check_prerequisites +#@ex workflow_check_prerequisites #@const JQ (read-only) #@return 255 if the prerequisites are not met -workflow::check_prerequisites() { +workflow_check_prerequisites() { log::debug "Check prerequisites for workflow" local status=0 @@ -32,12 +32,12 @@ workflow::check_prerequisites() { } #@desc Check if the workflow definition file exists. -#@ex workflow::check_workflow_definition_path +#@ex workflow_check_workflow_definition_path #@arg workflow_definition_path: path to the workflow definition file #@stderr Writes the fatal message to stdout if the workflow definition file does not exist and exit 255 #@stdout Writes the info message to stdout if the workflow definition file exists #@return workflow_definition_path: path to the workflow definition file -workflow::check_workflow_definition_path() { +workflow_check_workflow_definition_path() { local path="${1:-}" log::debug "Check workflow definition path" @@ -57,12 +57,12 @@ workflow::check_workflow_definition_path() { } #@desc Get containers' names from a JSON workflow definition. -#@ex workflow::workflow::get_workflows_containers_names \"config/workflow-default.json\" +#@ex workflow::workflow_get_workflows_containers_names \"config/workflow-default.json\" #@const JQ (read-only) #@const workflow_definition_path (read-only) #@stdout Writes debug messages to stdout #@return All found containers' names of the workflow as array -workflow::get_workflows_containers_names() { +workflow_get_workflows_containers_names() { local workflow_definition_path="${1:-}" local containers_names=() @@ -81,14 +81,14 @@ workflow::get_workflows_containers_names() { } #@desc Load step definition from an item and the workflow definition file. -#@ex workflow::load_step_definition \"step1\" \"config/workflow-default.json\" +#@ex workflow_load_step_definition \"step1\" \"config/workflow-default.json\" #@const JQ (read-only) #@const workflow_definition_path (read-only) #@arg item_id: id of the item to load #@arg workflow_definition_path: path to the workflow definition file #@stdout Writes debug messages to stdout #@return Step definition as array -workflow::load_workflow_definition() { +workflow_load_workflow_definition() { local item_id="${1:-}" local workflow_definition_path="${2:-}" @@ -103,12 +103,12 @@ workflow::load_workflow_definition() { } #@desc Load step values as environment variables from a step definition as JSON. -#@ex workflow::load_step_values \"[\"id\":\"step1\",\"name\":\"Step 1\",\"description\":\"Step 1 description\",\"type\":\"command\",\"command\":\"echo 'Step 1'\"]\" +#@ex workflow_load_step_values \"[\"id\":\"step1\",\"name\":\"Step 1\",\"description\":\"Step 1 description\",\"type\":\"command\",\"command\":\"echo 'Step 1'\"]\" #@const JQ (read-only) #@arg step_definition: step definition to load #@stdout Writes debug messages to stdout #@return The step values -workflow::load_step_values() { +workflow_load_step_values() { local step_definition="${1}" local initializer # shellcheck disable=SC2128 disable=SC2086 @@ -120,11 +120,11 @@ workflow::load_step_values() { } #@desc Iterate over workflow. -#@ex workflow::iterate_over_workflow \"config/workflow-default.json\" \"action1 action2 action3\" +#@ex workflow_iterate_over_workflow \"config/workflow-default.json\" \"action1 action2 action3\" #@const workflow_definition_path (read-only) #@arg workflow_definition_path: path to the workflow definition file #@arg workflows_id: array of workflows id -workflow::iterate_over_workflow() { +workflow_iterate_over_workflow() { local workflow_definition_path="${1}" shift local workflows_id=("$@") @@ -134,36 +134,36 @@ workflow::iterate_over_workflow() { local step_definition # shellcheck disable=SC2207 - step_definition=($(workflow::load_workflow_definition "$item" "$workflow_definition_path")) + step_definition=($(workflow_load_workflow_definition "$item" "$workflow_definition_path")) # shellcheck disable=SC2128 disable=SC2145 log::debug "Step definition is ${step_definition[@]}" - workflow::load_step_values "${step_definition[@]}" + workflow_load_step_values "${step_definition[@]}" done } #@desc Load workflow definition from a file. -#@ex workflow::load \"config/workflow-default.json\" +#@ex workflow_load \"config/workflow-default.json\" #@const JQ (read-only) #@arg workflow_definition_path: path to the workflow definition file #@stdout Writes the workflow definition details to stdout -workflow::load() { - local workflow_definition_path="${1:-}" - - workflow_definition_path=$(workflow::check_workflow_definition_path "$workflow_definition_path") - workflow::check_prerequisites - - local workflows_id=() - # shellcheck disable=SC2207 - workflows_id+=($(workflow::get_workflows_id "$workflow_definition_path")) - - # shellcheck disable=SC2145 - log::debug "Caller Workflows id are: ${workflows_id[@]}" - log::debug "Length Workflows id are: ${#workflows_id[@]}" - - workflow::iterate_over_workflow "$workflow_definition_path" "${workflows_id[@]}" -} +#workflow_load() { +# local workflow_definition_path="${1:-}" +# +# workflow_definition_path=$(workflow_check_workflow_definition_path "$workflow_definition_path") +# workflow_check_prerequisites +# +# local workflows_id=() +# # shellcheck disable=SC2207 +# workflows_id+=($(workflow::get_workflows_id "$workflow_definition_path")) +# +# # shellcheck disable=SC2145 +# log::debug "Caller Workflows id are: ${workflows_id[@]}" +# log::debug "Length Workflows id are: ${#workflows_id[@]}" +# +# workflow_iterate_over_workflow "$workflow_definition_path" "${workflows_id[@]}" +#} # Call the load function with the specified workflow definition path -# workflow::load "config/workflow-default.json" +# workflow_load "config/workflow-default.json" diff --git a/vars/wildPipeline.groovy b/vars/wildPipeline.groovy index 2a18392..d588397 100644 --- a/vars/wildPipeline.groovy +++ b/vars/wildPipeline.groovy @@ -61,7 +61,7 @@ def call() { script: ''' #!/usr/bin/env bash source ${wild_path}/src/lib/workflow.sh - workflow::get_workflows_containers_names ${wild_path}/test/config/workflow-default.json + workflow_get_workflows_containers_names ${wild_path}/test/config/workflow-default.json ''', returnStdout: true) }