Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build-gradle/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ gradle_build() {

if [[ "$SONAR_PLATFORM" == "none" ]]; then
# Build without sonar - call gradle_build_and_analyze directly
echo "::group::Gradle build"
gradle_build_and_analyze
echo "::endgroup::"
else
# Build with sonar analysis via orchestrator
# shellcheck disable=SC2119
Expand Down Expand Up @@ -265,9 +267,15 @@ export_built_artifacts() {
}

main() {
echo "::group::Check tools"
check_tool java -version
set_gradle_cmd
echo "::endgroup::"

echo "::group::Configure build environment"
set_build_env
echo "::endgroup::"

gradle_build
}

Expand Down
6 changes: 6 additions & 0 deletions build-maven/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,15 @@ should_scan() {
}

build_maven() {
echo "::group::Check tools"
check_tool mvn --version
check_settings_xml
echo "::endgroup::"

if should_scan; then
echo "::group::Fetch Git history"
git_fetch_unshallow
echo "::endgroup::"
else
echo "Skipping git fetch (Sonar analysis disabled)"
fi
Expand All @@ -164,6 +168,7 @@ build_maven() {
maven_command_args+=("-Pcoverage")
fi

echo "::group::Maven build"
if is_default_branch || is_maintenance_branch; then
echo "======= Build and analyze $GITHUB_REF_NAME ======="
if [[ "${RUN_SHADOW_SCANS}" != "true" ]]; then
Expand All @@ -187,6 +192,7 @@ build_maven() {
mvn_output=$(mktemp)
echo "Maven command: mvn ${maven_command_args[*]} $*"
mvn "${maven_command_args[@]}" "$@" | tee "$mvn_output"
echo "::endgroup::"

if should_deploy; then
echo "$DEPLOYED_OUTPUT_KEY=true" >> "$GITHUB_OUTPUT"
Expand Down
10 changes: 10 additions & 0 deletions build-maven/deploy-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ done

build_name="${GITHUB_REPOSITORY#*/}"
pushd "$MAVEN_CONFIG/repository"

echo "::group::Configure JFrog deployment"
jfrog config add deploy --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_DEPLOY_ACCESS_TOKEN"
jfrog config use deploy
echo "::endgroup::"

echo "::group::Deploy public artifacts"
echo "Deploying public artifacts..."
for artifact in "${public_artifacts[@]}"; do
jfrog rt u --build-name "$build_name" --build-number "$BUILD_NUMBER" "$artifact" "${ARTIFACTORY_DEPLOY_REPO}"
done
echo "::endgroup::"

echo "::group::Deploy private artifacts"
echo "Deploying private artifacts..."
jfrog config edit deploy --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN"
for artifact in "${private_artifacts[@]}"; do
jfrog rt u --build-name "$build_name" --build-number "$BUILD_NUMBER" "$artifact" "${ARTIFACTORY_PRIVATE_DEPLOY_REPO}"
done
echo "::endgroup::"

popd
15 changes: 13 additions & 2 deletions build-npm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,36 @@ get_build_config() {

# Complete build pipeline with optional steps
run_standard_pipeline() {
echo "::group::Install dependencies"
echo "Installing npm dependencies..."
npm ci --ignore-scripts
echo "::endgroup::"

if [ "$SKIP_TESTS" != "true" ]; then
echo "::group::Run tests"
echo "Running tests..."
npm test
echo "::endgroup::"
else
echo "Skipping tests (SKIP_TESTS=true)"
fi

if [ "${BUILD_ENABLE_SONAR}" = "true" ]; then
read -ra sonar_args <<< "$BUILD_SONAR_ARGS"
# This will call back to shared sonar_scanner_implementation() function
# orchestrate_sonar_platforms emits its own groups
orchestrate_sonar_platforms "${sonar_args[@]+${sonar_args[@]}}"
fi

echo "::group::Build project"
echo "Building project..."
npm run build
echo "::endgroup::"

if [ "${BUILD_ENABLE_DEPLOY}" = "true" ]; then
echo "::group::Publish to Artifactory"
jfrog_npm_publish
echo "::endgroup::"
export_built_artifacts
fi
}
Expand Down Expand Up @@ -256,10 +265,12 @@ main() {
check_tool jf --version
check_tool npm --version
echo "::endgroup::"

echo "::group::Fetch Git history"
git_fetch_unshallow
echo "::group::Build"
build_npm
echo "::endgroup::"

build_npm
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
Expand Down
15 changes: 15 additions & 0 deletions build-poetry/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,22 +277,32 @@ build_poetry() {
echo "Pull Request: ${PULL_REQUEST}"
echo "Deploy Pull Request: ${DEPLOY_PULL_REQUEST}"

echo "::group::Set project version"
set_project_version
echo "::endgroup::"

get_build_config

echo "::group::Install dependencies"
echo "Installing dependencies..."
jfrog_poetry_install
echo "::endgroup::"

echo "::group::Build project"
echo "Building project..."
poetry build
echo "::endgroup::"

if [ "${BUILD_ENABLE_SONAR}" = "true" ]; then
read -ra sonar_args <<< "$BUILD_SONAR_ARGS"
# run_sonar_analysis emits its own groups
run_sonar_analysis "${sonar_args[@]+${sonar_args[@]}}"
fi

if [ "${BUILD_ENABLE_DEPLOY}" = "true" ]; then
echo "::group::Publish to Artifactory"
jfrog_poetry_publish
echo "::endgroup::"
export_built_artifacts
fi

Expand Down Expand Up @@ -328,12 +338,17 @@ export_built_artifacts() {
}

main() {
echo "::group::Check tools"
check_tool jq --version
check_tool python --version
check_tool poetry --version
check_tool jf --version
echo "::endgroup::"

echo "::group::Configure build environment"
set_build_env
echo "::endgroup::"

build_poetry
}

Expand Down
18 changes: 18 additions & 0 deletions build-yarn/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,27 +255,36 @@ get_build_config() {

# Complete build pipeline with optional steps
run_standard_pipeline() {
echo "::group::Install dependencies"
echo "Installing yarn dependencies..."
yarn install --immutable
echo "::endgroup::"

if [ "$SKIP_TESTS" != "true" ]; then
echo "::group::Run tests"
echo "Running tests..."
yarn test
echo "::endgroup::"
else
echo "Skipping tests (SKIP_TESTS=true)"
fi

if [ "${BUILD_ENABLE_SONAR}" = "true" ]; then
read -ra sonar_args <<< "$BUILD_SONAR_ARGS"
# This will call back to shared sonar_scanner_implementation() function
# orchestrate_sonar_platforms emits its own groups
orchestrate_sonar_platforms "${sonar_args[@]+${sonar_args[@]}}"
fi

echo "::group::Build project"
echo "Building project..."
yarn build
echo "::endgroup::"

if [ "${BUILD_ENABLE_DEPLOY}" = "true" ]; then
echo "::group::Publish to Artifactory"
jfrog_yarn_publish
echo "::endgroup::"
export_built_artifacts
fi
}
Expand All @@ -289,7 +298,10 @@ build_yarn() {
echo "Sonar Platform: ${SONAR_PLATFORM}"
echo "Run Shadow Scans: ${RUN_SHADOW_SCANS}"

echo "::group::Set project version"
set_project_version
echo "::endgroup::"

get_build_config
run_standard_pipeline

Expand Down Expand Up @@ -324,10 +336,16 @@ export_built_artifacts() {
}

main() {
echo "::group::Check tools"
check_tool jq --version
check_tool jf --version
check_tool yarn --version
echo "::endgroup::"

echo "::group::Configure build environment"
set_build_env
echo "::endgroup::"

build_yarn
}

Expand Down
4 changes: 4 additions & 0 deletions config-gradle/set_gradle_project_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "current-version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "project-version=$PROJECT_VERSION" >> "$GITHUB_OUTPUT"
else
echo "::group::Check tools"
set_gradle_cmd
echo "::endgroup::"
echo "::group::Set project version"
set_project_version
echo "::endgroup::"
fi
fi
4 changes: 4 additions & 0 deletions config-maven/set_maven_project_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "current-version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "project-version=$PROJECT_VERSION" >> "$GITHUB_OUTPUT"
else
echo "::group::Check tools"
check_tool mvn --version
echo "::endgroup::"
echo "::group::Set project version"
set_project_version
echo "::endgroup::"
fi
fi
12 changes: 12 additions & 0 deletions promote/promote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,26 @@ EOF
}

promote() {
echo "::group::Check tools"
check_tool gh --version
check_tool jq --version
check_tool jf --version
echo "::endgroup::"

echo "::group::Configure promotion"
set_build_env
check_branch
jfrog_config_repox
echo "::endgroup::"

echo "::group::Promote build artifacts"
jfrog_promote
echo "::endgroup::"

echo "::group::Notify GitHub"
github_notify_promotion
echo "::endgroup::"

generate_workflow_summary
}

Expand Down
2 changes: 2 additions & 0 deletions shared/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ orchestrate_sonar_platforms() {
done
echo "=== ORCHESTRATOR: Completed Sonar analysis on all platforms ==="
else
echo "::group::Sonar analysis on $SONAR_PLATFORM"
echo "=== ORCHESTRATOR: Running Sonar analysis on selected platform: $SONAR_PLATFORM ==="
set_sonar_platform_vars "$SONAR_PLATFORM"
# CALLBACK: Hand control back to build script's implementation
sonar_scanner_implementation "$@"
echo "::endgroup::"
fi
}

Expand Down
12 changes: 8 additions & 4 deletions spec/build-gradle_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,14 @@ Describe 'main function'

When call main
The status should be success
The line 1 should equal "java ok"
The line 2 should equal "gradle ok"
The line 3 should equal "env set"
The line 4 should equal "build done"
The line 1 should equal "::group::Check tools"
The line 2 should equal "java ok"
The line 3 should equal "gradle ok"
The line 4 should equal "::endgroup::"
The line 5 should equal "::group::Configure build environment"
The line 6 should equal "env set"
The line 7 should equal "::endgroup::"
The line 8 should equal "build done"
End
End

Expand Down
26 changes: 16 additions & 10 deletions spec/build-maven_deploy-artifacts_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ com/sonarsource/private/app/1.0/app-1.0.jar"

When run script build-maven/deploy-artifacts.sh
The status should be success
The lines of stdout should equal 11
The line 2 of output should equal "jfrog config add deploy --artifactory-url https://dummy.repox --access-token deploy-token"
The line 3 of output should equal "jfrog config use deploy"
The line 4 of output should include "Deploying public artifacts..."
The line 5 of output should include "org/sonarsource/app/1.0/app-1.0.pom deploy-repo-qa"
The line 6 of output should include "org/sonarsource/app/1.0/app-1.0.jar deploy-repo-qa"
The line 7 of output should equal "Deploying private artifacts..."
The line 8 of output should equal "jfrog config edit deploy --artifactory-url https://dummy.repox --access-token private-token"
The line 9 of output should include "com/sonarsource/private/app/1.0/app-1.0.pom private-repo-qa"
The line 10 of output should include "com/sonarsource/private/app/1.0/app-1.0.jar private-repo-qa"
The lines of stdout should equal 17
The line 2 of output should equal "::group::Configure JFrog deployment"
The line 3 of output should equal "jfrog config add deploy --artifactory-url https://dummy.repox --access-token deploy-token"
The line 4 of output should equal "jfrog config use deploy"
The line 5 of output should equal "::endgroup::"
The line 6 of output should equal "::group::Deploy public artifacts"
The line 7 of output should include "Deploying public artifacts..."
The line 8 of output should include "org/sonarsource/app/1.0/app-1.0.pom deploy-repo-qa"
The line 9 of output should include "org/sonarsource/app/1.0/app-1.0.jar deploy-repo-qa"
The line 10 of output should equal "::endgroup::"
The line 11 of output should equal "::group::Deploy private artifacts"
The line 12 of output should equal "Deploying private artifacts..."
The line 13 of output should equal "jfrog config edit deploy --artifactory-url https://dummy.repox --access-token private-token"
The line 14 of output should include "com/sonarsource/private/app/1.0/app-1.0.pom private-repo-qa"
The line 15 of output should include "com/sonarsource/private/app/1.0/app-1.0.jar private-repo-qa"
The line 16 of output should equal "::endgroup::"

rm -rf "$MAVEN_CONFIG"
End
Expand Down
Loading
Loading