diff --git a/build_scripts/appimage/appimage.sh b/build_scripts/appimage/appimage.sh index 032ae7663..5619d2525 100755 --- a/build_scripts/appimage/appimage.sh +++ b/build_scripts/appimage/appimage.sh @@ -35,8 +35,6 @@ setup_build_dir() { mkdir -p "$BUILD_DIR" - build_commit=$(git -C "$monkey_repo" rev-parse --short HEAD) - copy_monkey_island_to_build_dir "$monkey_repo/monkey" "$BUILD_DIR" copy_server_config_to_build_dir modify_deployment "$deployment_type" "$BUILD_DIR" @@ -107,7 +105,8 @@ remove_python_appdir_artifacts() { build_package() { local version=$1 - local dist_dir=$2 + local commit_id=$2 + local dist_dir=$3 log_message "Building AppImage" set_version "$version" @@ -125,7 +124,7 @@ build_package() { if $IS_RELEASE_BUILD; then dst_name="InfectionMonkey-v$version.AppImage" else - dst_name="InfectionMonkey-$build_commit.AppImage" + dst_name="InfectionMonkey-$commit_id.AppImage" fi move_package_to_dist_dir $dist_dir $dst_name diff --git a/build_scripts/build_package.sh b/build_scripts/build_package.sh index 26ca5588d..e787fdd35 100755 --- a/build_scripts/build_package.sh +++ b/build_scripts/build_package.sh @@ -198,7 +198,8 @@ install_package_specific_build_prereqs "$WORKSPACE" setup_build_dir "$agent_binary_dir" "$monkey_repo" "$deployment_type" -build_package "$monkey_version" "$DIST_DIR" +commit_id=$(get_commit_id "$monkey_repo") +build_package "$monkey_version" "$commit_id" "$DIST_DIR" log_message "Finished building package: $package" exit 0 diff --git a/build_scripts/common.sh b/build_scripts/common.sh index a8e7c190a..2f244fd51 100644 --- a/build_scripts/common.sh +++ b/build_scripts/common.sh @@ -93,3 +93,8 @@ remove_node_modules() { rm -rf "$1/node_modules" rm -rf "$1/.npm" } + +get_commit_id() { + local monkey_repo=$1 + echo $(git -C "$monkey_repo" rev-parse --short HEAD) +} diff --git a/build_scripts/docker/docker.sh b/build_scripts/docker/docker.sh index 519cc54d0..42004f8f7 100755 --- a/build_scripts/docker/docker.sh +++ b/build_scripts/docker/docker.sh @@ -15,8 +15,6 @@ setup_build_dir() { copy_entrypoint_to_build_dir "$build_dir" - build_commit=$(git -C "$monkey_repo" rev-parse --short HEAD) - copy_monkey_island_to_build_dir "$monkey_repo/monkey" "$build_dir" copy_server_config_to_build_dir "$build_dir" modify_deployment "$deployment_type" "$build_dir" @@ -38,13 +36,14 @@ copy_server_config_to_build_dir() { build_package() { local version=$1 - local dist_dir=$2 + local commit_id=$2 + local dist_dir=$3 pushd ./docker if [ -n "$1" ]; then version="v$version" else - version="$build_commit" + version="$commit_id" fi docker_image_name="guardicore/monkey-island:$version"