From 6bd1f30d8100d12cb48b046bde23ca6320424e79 Mon Sep 17 00:00:00 2001 From: Simon Meggle Date: Tue, 23 Aug 2022 12:32:10 +0200 Subject: [PATCH] Fixed bug in build.sh (missing bakery file) --- .devcontainer/build.sh | 28 +++++++++++++++++++++------- CHANGELOG.md | 2 +- DEVELOPMENT.md | 10 ++++++++++ package/v2/pkginfo | 5 +---- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index d28b2e44..998ebb99 100755 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -10,6 +10,17 @@ set -e # After the MKP has been built, the script check if it runs within a Github # Workflow. If so, it sets the artifact name as output variable. +if [ -z $WORKSPACE ]; then + echo "ERROR: WORKSPACE environment variable not set. Exiting." + exit 1 +fi + +if [ -z $OMD_SITE ]; then + echo "ERROR: You do not seem to be on a OMD site (variable OMD_SITE not set). Exiting." + exit 1 +fi + +set -u # CMK Major version MVERSION="$(cat $OMD_ROOT/.version_meta/version | cut -d '.' -f1)" NAME="robotmk" @@ -18,18 +29,18 @@ PACKAGEFILE=$OMD_ROOT/var/check_mk/packages/$NAME # get the current tag (Release) or commit hash (Artifact) export RMK_VERSION=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) - +echo "▹ Removing old packages..." rm -f $OMD_ROOT/var/check_mk/packages/* echo "---------------------------------------------" -echo "* Merging the common package info with version $MVERSION specific..." +echo "▹ Merging the common package info with version $MVERSION specific..." jq -s '.[0] * .[1]' $WORKSPACE/package/pkginfo_common $WORKSPACE/package/v$MVERSION/pkginfo | jq '. + {version:env.RMK_VERSION}' > $PACKAGEFILE echo "---------------------------------------------" echo "$PACKAGEFILE:" cat $PACKAGEFILE echo "---------------------------------------------" -echo "* Building MKP '$NAME' on $RMK_VERSION for CMK version $MVERSION..." -set -x +echo "▹ Building MKP '$NAME' on $RMK_VERSION for CMK version $MVERSION..." +# set -x ls -la $PACKAGEFILE mkp -v pack $NAME FILE=$(ls -rt1 *.mkp | tail -1) @@ -38,9 +49,12 @@ FILE=$(ls -rt1 *.mkp | tail -1) NEWFILENAME=$NAME.$RMK_VERSION-cmk$MVERSION.mkp mv $FILE $NEWFILENAME echo "---------------------------------------------" +echo "📦 Package:" +echo "$NEWFILENAME" + -if [ -n "$GITHUB_WORKSPACE" ]; then - echo "* Set Outputs for GitHub Workflow steps" +if [ -n "${GITHUB_WORKSPACE-}" ]; then + echo "▹ Set Outputs for GitHub Workflow steps" echo "::set-output name=pkgfile::$NEWFILENAME" # echo "::set-output name=pkgname::${NAME}" VERSION=$(jq -r '.version' $PACKAGEFILE) @@ -48,7 +62,7 @@ if [ -n "$GITHUB_WORKSPACE" ]; then # echo "::set-output name=cmkmversion::$MVERSION" echo "::set-output name=artifactname::$NEWFILENAME" else - echo "* (No GitHub Workflow detected)" + echo "(No GitHub Workflow detected)" fi echo "END OF build.sh" echo "---------------------------------------------" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 726313b7..cbcb6f80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* Documentation: Added [FAQs](./FAQ.md) with design decicions +* Documentation: Added [FAQs](./FAQ.md) with design decisions * Check: Added the possibility to temporarily skip the execution of suites by placing a `DISABLED` (case sensitive) file in the suite's root folder. (#192) Robotmk will silently ignore this suite as long the DISABLED file is there. (Thanks Marcus for this suggestion - this is the perfect alternative to commenting out the suite in `robotmk.yml` manually). diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index f735b877..ac7fec0b 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -210,6 +210,16 @@ Debugging `robotmk.py` and `robotmk-runner.py` from the devcontainer is not stra After that, set a breakpoint in VS Code in `agents_plugins/robotmk-runner.py`. Also select the debugging configuration to "devc V2.x robotmk-runner" and press F5 to start debugging. +### Building a MKP inside of the Container + +To test how the Github workflow will build MKPs for Robotmk, you can run the build script within the container locally. + +In VS Code, +- run command "Tasks chooser: Select Task" => "Build Robotmk MKP" +- run command "Tasks: run task" to execute the build script + +- + ### Write a changelog Robotmk's [CHANGELOG.md](CHANGELOG.md) is based on [](https://keepachangelog.com/). diff --git a/package/v2/pkginfo b/package/v2/pkginfo index bea4ae37..93641f0a 100644 --- a/package/v2/pkginfo +++ b/package/v2/pkginfo @@ -2,9 +2,6 @@ "version.min_required": "2.0.0", "files": { "agent_based": ["robotmk.py"], - "agents": ["plugins/robotmk-runner.py", "plugins/robotmk.py"], - "lib": [ - "check_mk/base/cee/plugins/bakery/robotmk.py" - ] + "agents": ["plugins/robotmk-runner.py", "plugins/robotmk.py", "bakery/robotmk.py"] } } \ No newline at end of file