Skip to content

Commit

Permalink
fix: Display pipeline URL after triggering env-release-system (IN-135…
Browse files Browse the repository at this point in the history
…8) (#279)

* fix: Display pipeline URL after triggering env-release-system (IN-1358)

* fixed wrong usage of jq
  • Loading branch information
junydania authored Jul 30, 2024
1 parent a722518 commit 33a3a23
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/commands/vfcli/vfcli-delete-or-release-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,34 @@ steps:
echo "Resetting the database for $env_name"
vfcli pool release-env --env-name "$env_name"
echo "Triggering pipeline with env-name parameter"
response=$(curl -s -o /dev/null -w "%{http_code}" \
response=$(curl -s -w "\n%{http_code}" \
--request POST \
--url "https://circleci.com/api/v2/project/gh/voiceflow/env-release-system/pipeline" \
--header "Circle-Token: ${CIRCLECI_API_TOKEN}" \
--header "content-type: application/json" \
--data "{\"parameters\":{\"e2e_env_name\":\"$env_name\",\"trigger_pipeline\":true}}")
if [[ $response == "201" ]]; then
echo "Env Release Pipeline triggered successfully. Exiting with success."
exit 0
http_status=$(echo "$response" | tail -n1)
response_body=$(echo "$response" | sed '$d')
if [[ $http_status == "201" || $http_status == "200" ]]; then
if echo "$response_body" | jq empty 2>/dev/null; then
pipeline_id=$(echo "$response_body" | jq -r '.id // empty')
pipeline_number=$(echo "$response_body" | jq -r '.number // empty')
if [[ -n $pipeline_number ]]; then
pipeline_url="https://app.circleci.com/pipelines/github/voiceflow/env-release-system/$pipeline_number"
echo "Env Release Pipeline triggered successfully."
echo "Pipeline URL: $pipeline_url"
echo "Pipeline ID: $pipeline_id"
echo "Exiting with success."
exit 0
else
echo "Failed to retrieve pipeline number. Response body: $response_body"
fi
else
echo "Response is not valid JSON. Response body: $response_body"
fi
else
echo "Failed to trigger pipeline. HTTP status code: $response"
echo "Failed to trigger pipeline. HTTP status code: $http_status"
echo "Response body: $response_body"
fi
fi
vfcli env resume "$env_name" --interactive false
Expand Down

0 comments on commit 33a3a23

Please sign in to comment.