-
Notifications
You must be signed in to change notification settings - Fork 0
fix: update script files #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/bin/bash | ||
|
|
||
| ${OC} create -f "${JOB_UNINSTALL_CPD_FILENAME}" | ||
| RC=$? | ||
| if [ "${RC}" -ne 0 ]; then echo "Unable to create job ${JOB_NAME}; exiting..." && exit 1; fi | ||
|
|
||
| timeout_seconds=1800 # 30 minutes | ||
| sleep_seconds=5 | ||
| number_of_tries=$((timeout_seconds / sleep_seconds)) | ||
| complete=false | ||
| failed=false | ||
|
|
||
| i=0 | ||
| while [ $i -lt "${number_of_tries}" ]; do | ||
|
|
||
| echo "Running job ... $i" | ||
| ${OC} get jobs -n "${NAMESPACE_NAME}" | ||
|
|
||
| ${OC} wait --for=condition=complete job "${JOB_NAME}" -n "${NAMESPACE_NAME}" --timeout=0 2>/dev/null | ||
vburckhardt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RC=$? | ||
| if [ "${RC}" -eq 0 ]; then complete=true && break; fi | ||
|
|
||
| ${OC} wait --for=condition=failed job "${JOB_NAME}" -n "${NAMESPACE_NAME}" --timeout=0 2>/dev/null | ||
| RC=$? | ||
| if [ "${RC}" -eq 0 ]; then failed=true && break; fi | ||
|
|
||
| i=$((i+1)) | ||
|
|
||
| sleep "${sleep_seconds}" | ||
|
|
||
| done | ||
|
|
||
| ${OC} describe pods -n "${NAMESPACE_NAME}" | ||
|
|
||
| if $failed; then | ||
| echo "Job ${JOB_NAME} failed" | ||
| exit 1 | ||
| elif "${complete}"; then | ||
| echo "Job ${JOB_NAME} completed successfully" | ||
| ${OC} delete -f "${JOB_UNINSTALL_CPD_FILENAME}" | ||
| RC=$? | ||
| if [ "${RC}" -ne 0 ]; then echo "Unable to delete job ${JOB_NAME}; exiting..." && exit 1; fi | ||
| exit 0 | ||
| fi | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| BUILD_OUTPUT=$(curl -X POST "https://api.${REGION}.codeengine.cloud.ibm.com/v2/projects/${PROJECT_ID}/build_runs" -H "Authorization: ${TOKEN}" -H "Content-Type: application/json" -d '{ "build_name": "cpd-build" }') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not possible to use the provider? https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/code_engine_build
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do create the project/build/etc through the code engine DA. The problem is executing a build run and checking for completion which there is no terraform for |
||
| RC=$? | ||
|
|
||
| BUILD_NAME=$(echo "${BUILD_OUTPUT}" | jq -r .name) | ||
|
|
||
| if [ $RC -ne 0 ] || [ "${BUILD_NAME}" == "null" ]; then | ||
| echo "Creation of build run failed with rc = ${RC}. Output = ${BUILD_OUTPUT}" | ||
| exit 1; | ||
| fi | ||
|
|
||
| SLEEP_SECONDS=60 | ||
| NUMBER_OF_RETRIES=15 | ||
| COMPLETE=false | ||
|
|
||
| i=0 | ||
| while [ "${i}" -lt "${NUMBER_OF_RETRIES}" ]; do | ||
|
|
||
| echo "Running job ... $i" | ||
|
|
||
| BUILD_RUN_OUTPUT=$(curl -X GET "https://api.${REGION}.codeengine.cloud.ibm.com/v2/projects/${PROJECT_ID}/build_runs/${BUILD_NAME}" -H "Authorization: ${TOKEN}") | ||
| echo "${BUILD_RUN_OUTPUT}" | ||
|
|
||
| BUILD_STATUS=$(echo "${BUILD_RUN_OUTPUT}" | jq -r .status) | ||
| if [ "${BUILD_STATUS}" == "succeeded" ]; then COMPLETE=true && break; fi | ||
|
|
||
| i=$((i+1)) | ||
|
|
||
| sleep "${SLEEP_SECONDS}" | ||
| done | ||
|
|
||
| if [ "${COMPLETE}" = false ]; then | ||
| echo "The build run did not complete in the alloted time. Output = ${BUILD_RUN_OUTPUT}" | ||
| exit 1; | ||
| fi | ||
|
|
||
| exit 0; | ||
Uh oh!
There was an error while loading. Please reload this page.