Skip to content

Commit

Permalink
added id, modified README (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivannalisetska authored Dec 10, 2024
1 parent 2cd13c0 commit 56e54a2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ steps:
- label: ":sparkles: Lint"
plugins:
- plugin-linter#v3.3.0:
id: custom-checkout

- label: ":shell: Shellcheck"
plugins:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ A Buildkite plugin for customizing repository checkouts in your pipeline. This p
```yaml
steps:
- label: "Skip checkout"
command: echo "Skipping checkout"
command: 'echo "Skipping checkout"'
plugins:
- https://github.com/buildkite-plugins/custom-checkout-buildkite-plugin.git:
- buildkite-plugins/custom-checkout#v1.0.0:
skip_checkout: true
```
Expand All @@ -32,7 +32,7 @@ steps:
- label: "Custom repository checkout"
command: "buildkite-agent pipeline upload"
plugins:
- https://github.com/buildkite-plugins/custom-checkout-buildkite-plugin.git:
- buildkite-plugins/custom-checkout#v1.0.0:
skip_checkout: true
repos:
- url: "https://github.com/org/repo.git"
Expand Down Expand Up @@ -67,9 +67,9 @@ Each repository in the `repos` list can have the following options:
```yaml
steps:
- label: "Skip checkout"
command: "echo "Skipping checkout"
command: 'echo "Skipping checkout"'
plugins:
- https://github.com/buildkite-plugins/custom-checkout-buildkite-plugin.git:
- buildkite-plugins/custom-checkout#v1.0.0:
skip_checkout: true
```

Expand All @@ -80,7 +80,7 @@ steps:
- label: "Custom checkout"
command: "buildkite-agent pipeline upload"
plugins:
- https://github.com/buildkite-plugins/custom-checkout-buildkite-plugin.git:
- buildkite-plugins/custom-checkout#v1.0.0:
skip_checkout: true
repos:
- url: "https://github.com/org/repo.git"
Expand All @@ -93,7 +93,7 @@ steps:
- label: "Multiple repos"
command: "./script.sh"
plugins:
- https://github.com/buildkite-plugins/custom-checkout-buildkite-plugin.git:
- buildkite-plugins/custom-checkout#v1.0.0:
skip_checkout: true
repos:
- url: "https://github.com/org/repo1.git"
Expand Down
22 changes: 14 additions & 8 deletions hooks/checkout
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ set -euo pipefail

# Functions
log_section() {
echo -e "\n--- $1"
echo -e "\n🔷 --- $1"
}

log_info() {
echo -e "INFO: $1"
echo -e "\033[36mℹ️ INFO:\033[0m $1"
}

log_success() {
echo -e "\033[32m✅ SUCCESS:\033[0m $1"
}

log_warning() {
echo -e "\033[33m⚠️ WARNING:\033[0m $1"
}

log_error() {
echo -e "ERROR: $1" >&2
echo -e "\033[31m❌ ERROR:\033[0m $1" >&2
}

check_required_env() {
Expand Down Expand Up @@ -115,11 +123,11 @@ log_section ":open_file_folder: Setting up workspace"

# Check for skip checkout
if [[ "${BUILDKITE_PLUGIN_CUSTOM_CHECKOUT_SKIP_CHECKOUT:-false}" == "true" ]]; then
log_info "Skipping default checkout as per configuration."
log_warning "🚫 Skipping default checkout as per configuration."

# If we're just skipping checkout and no repos are specified, exit successfully
if [[ -z "${BUILDKITE_PLUGIN_CUSTOM_CHECKOUT_REPOS_0:-}" && -z "${BUILDKITE_PLUGIN_CUSTOM_CHECKOUT_REPOS_0_URL:-}" ]]; then
log_info "No repositories configured for checkout, skipping repository checkout"
log_info "📝 No repositories configured for checkout, skipping repository checkout"
exit 0
fi
fi
Expand Down Expand Up @@ -162,15 +170,13 @@ while true; do

REPO_REF_VAR="BUILDKITE_PLUGIN_CUSTOM_CHECKOUT_REPOS_${REPOS_COUNT}_REF"
REPO_SSH_KEY_VAR="BUILDKITE_PLUGIN_CUSTOM_CHECKOUT_REPOS_${REPOS_COUNT}_SSH_KEY_PATH"
REPO_CLONE_FLAGS_VAR="BUILDKITE_PLUGIN_CUSTOM_CHECKOUT_REPOS_${REPOS_COUNT}_CLONE_FLAGS"

REPO_REF="${!REPO_REF_VAR:-}"
REPO_SSH_KEY_PATH="${!REPO_SSH_KEY_VAR:-}"
REPO_CLONE_FLAGS=()

if clone_repository "$REPO_URL" "$REPO_REF" "$REPO_SSH_KEY_PATH" "$BUILDKITE_BUILD_CHECKOUT_PATH" "${REPO_CLONE_FLAGS[@]+"${REPO_CLONE_FLAGS[@]}"}"; then
CLONE_SUCCESS=true
log_info "Successfully cloned repository $REPO_URL"
log_success "Successfully cloned repository $REPO_URL"
else
log_error "Failed to clone repository $REPO_URL"
exit 1
Expand Down

0 comments on commit 56e54a2

Please sign in to comment.