Skip to content
Merged
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
32 changes: 18 additions & 14 deletions lib/bin/build_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,26 @@ elif [ -n "$SEMAPHORE" ]; then
pr_title=$SEMAPHORE_GIT_PR_NAME
fi

function escape() {
echo -n "$1" | sed 's/"/\\"/g'
}

# Output the JSON
cat <<EOF
{
"api_key": "$SELECTIVE_API_KEY",
"host": "${SELECTIVE_HOST:-wss://app.selective.ci}",
"platform": "${SELECTIVE_PLATFORM:-$platform}",
"branch": "${SELECTIVE_BRANCH:-$branch}",
"pr_title": "${SELECTIVE_PR_TITLE:-$pr_title}",
"target_branch": "${SELECTIVE_TARGET_BRANCH:-$target_branch}",
"actor": "${SELECTIVE_ACTOR:-$actor}",
"sha": "${SELECTIVE_SHA:-$sha}",
"run_id": "${SELECTIVE_RUN_ID:-$run_id}",
"run_attempt": "${SELECTIVE_RUN_ATTEMPT:-$run_attempt}",
"runner_id": "${SELECTIVE_RUNNER_ID:-$runner_id}",
"commit_message": "$(git log --format=%s -n 1 $sha)",
"committer_name": "$(git show -s --format='%an' -n 1 $sha)",
"committer_email": "$(git show -s --format='%ae' -n 1 $sha)"
"api_key": "$(escape "${SELECTIVE_API_KEY}")",
"host": "$(escape "${SELECTIVE_HOST:-wss://app.selective.ci}")",
"platform": "$(escape "${SELECTIVE_PLATFORM:-$platform}")",
"branch": "$(escape "${SELECTIVE_BRANCH:-$branch}")",
"pr_title": "$(escape "${SELECTIVE_PR_TITLE:-$pr_title}")",
"target_branch": "$(escape "${SELECTIVE_TARGET_BRANCH:-$target_branch}")",
"actor": "$(escape "${SELECTIVE_ACTOR:-$actor}")",
"sha": "$(escape "${SELECTIVE_SHA:-$sha}")",
"run_id": "$(escape "${SELECTIVE_RUN_ID:-$run_id}")",
"run_attempt": "$(escape "${SELECTIVE_RUN_ATTEMPT:-$run_attempt}")",
"runner_id": "$(escape "${SELECTIVE_RUNNER_ID:-$runner_id}")",
"commit_message": "$(escape "$(git log --format=%s -n 1 $sha)")",
"committer_name": "$(escape "$(git show -s --format='%an' -n 1 $sha)")",
"committer_email": "$(escape "$(git show -s --format='%ae' -n 1 $sha)")"
}
EOF