Build: Refactor commit id

This commit is contained in:
Ilija Lazoroski 2021-10-21 17:02:37 +02:00
parent e406294b28
commit 6d827ad1af
4 changed files with 13 additions and 9 deletions

View File

@ -35,8 +35,6 @@ setup_build_dir() {
mkdir -p "$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_monkey_island_to_build_dir "$monkey_repo/monkey" "$BUILD_DIR"
copy_server_config_to_build_dir copy_server_config_to_build_dir
modify_deployment "$deployment_type" "$BUILD_DIR" modify_deployment "$deployment_type" "$BUILD_DIR"
@ -107,7 +105,8 @@ remove_python_appdir_artifacts() {
build_package() { build_package() {
local version=$1 local version=$1
local dist_dir=$2 local commit_id=$2
local dist_dir=$3
log_message "Building AppImage" log_message "Building AppImage"
set_version "$version" set_version "$version"
@ -125,7 +124,7 @@ build_package() {
if $IS_RELEASE_BUILD; then if $IS_RELEASE_BUILD; then
dst_name="InfectionMonkey-v$version.AppImage" dst_name="InfectionMonkey-v$version.AppImage"
else else
dst_name="InfectionMonkey-$build_commit.AppImage" dst_name="InfectionMonkey-$commit_id.AppImage"
fi fi
move_package_to_dist_dir $dist_dir $dst_name move_package_to_dist_dir $dist_dir $dst_name

View File

@ -198,7 +198,8 @@ install_package_specific_build_prereqs "$WORKSPACE"
setup_build_dir "$agent_binary_dir" "$monkey_repo" "$deployment_type" 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" log_message "Finished building package: $package"
exit 0 exit 0

View File

@ -93,3 +93,8 @@ remove_node_modules() {
rm -rf "$1/node_modules" rm -rf "$1/node_modules"
rm -rf "$1/.npm" rm -rf "$1/.npm"
} }
get_commit_id() {
local monkey_repo=$1
echo $(git -C "$monkey_repo" rev-parse --short HEAD)
}

View File

@ -15,8 +15,6 @@ setup_build_dir() {
copy_entrypoint_to_build_dir "$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_monkey_island_to_build_dir "$monkey_repo/monkey" "$build_dir"
copy_server_config_to_build_dir "$build_dir" copy_server_config_to_build_dir "$build_dir"
modify_deployment "$deployment_type" "$build_dir" modify_deployment "$deployment_type" "$build_dir"
@ -38,13 +36,14 @@ copy_server_config_to_build_dir() {
build_package() { build_package() {
local version=$1 local version=$1
local dist_dir=$2 local commit_id=$2
local dist_dir=$3
pushd ./docker pushd ./docker
if [ -n "$1" ]; then if [ -n "$1" ]; then
version="v$version" version="v$version"
else else
version="$build_commit" version="$commit_id"
fi fi
docker_image_name="guardicore/monkey-island:$version" docker_image_name="guardicore/monkey-island:$version"