Skip to content

Commit 90ab4d9

Browse files
feat: fix debug issues (#5)
1 parent 2fed33a commit 90ab4d9

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/commands/block_execution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: >
44
parameters:
55
debug:
66
type: boolean
7-
default: true
7+
default: false
88
description: "If enabled, DEBUG messages will be logged."
99
time:
1010
type: string

src/scripts/queue.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
debug() {
4-
if [ -n "${CONFIG_DEBUG_ENABLED}" ]; then
4+
if [ "${CONFIG_DEBUG_ENABLED}" == "1" ]; then
55
echo "DEBUG: ${*}"
66
fi
77
}
@@ -47,25 +47,22 @@ fetch_pipelines(){
4747
echo "Only blocking execution if running previous workflows on branch: ${CIRCLE_BRANCH}"
4848
pipelines_api_url_template="https://circleci.com/api/v2/project/gh/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pipeline?branch=${CIRCLE_BRANCH}"
4949

50-
debug "DEBUG Attempting to access CircleCI API. If the build process fails after this step, ensure your CIRCLECI_USER_AUTH is set."
50+
debug "Fetching piplines: ${pipelines_api_url_template} > ${pipeline_file}"
5151
fetch "${pipelines_api_url_template}" "${pipeline_file}"
52-
echo "DEBUG API access successful"
5352
}
5453

5554
fetch_pipeline_workflows(){
5655
for pipeline in $(jq -r ".items[] | .id //empty" ${pipeline_file} | uniq)
5756
do
58-
debug "Checking time of pipeline: ${pipeline}"
57+
debug "Fetching workflow information for pipeline: ${pipeline}"
5958
pipeline_detail=${tmp}/pipeline-${pipeline}.json
6059
fetch "https://circleci.com/api/v2/pipeline/${pipeline}/workflow" "${pipeline_detail}"
6160
created_at=$(jq -r '.items[] | .created_at' "${pipeline_detail}")
62-
debug "Pipeline was created at: ${created_at}"
61+
debug "Pipeline's workflow was created at: ${created_at}"
6362
done
6463
jq -s '[.[].items[] | select((.status == "running") or (.status == "created"))]' ${tmp}/pipeline-*.json > ${workflows_file}
65-
6664
}
6765

68-
# CIRCLE_BUILD_NUM is going to be for job, not for pipeline
6966
load_current_workflow_values(){
7067
my_commit_time=$(jq ".[] | select (.id == \"${CIRCLE_WORKFLOW_ID}\").created_at" ${workflows_file})
7168
my_workflow_id=$(jq ".[] | select (.id == \"${CIRCLE_WORKFLOW_ID}\").id" ${workflows_file})
@@ -78,11 +75,6 @@ update_comparables(){
7875

7976
load_current_workflow_values
8077

81-
# need to only get the workflows which are created or running
82-
83-
# need to pull out the workflows that are failed, and stuff, we need to only look for running ones
84-
# also need to make sure that job # and pipeline # are interchangable
85-
8678
echo "This job will block until no previous workflows have *any* workflows running."
8779
oldest_running_workflow_id=$(jq '. | sort_by(.created_at) | .[0].id' ${workflows_file})
8880
oldest_commit_time=$(jq '. | sort_by(.created_at) | .[0].created_at' ${workflows_file})

0 commit comments

Comments
 (0)