Skip to content

Commit 676589c

Browse files
committed
Add include-on-hold option to treat on-hold workflows as running in queue
1 parent 0022cc4 commit 676589c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/commands/block_execution.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ parameters:
2525
Due to concurrency issues, how many times should we requery the pipeline list to ensure previous jobs are "pending",
2626
but not yet active. This number indicates the threshold for API returning no previous pending pipelines.
2727
Default is one confirmation, increase if you see issues.
28+
include-on-hold:
29+
type: boolean
30+
default: true
31+
description: Consider on-hold workflows waiting for approval as running and include them in the queue.
2832

2933
steps:
3034
- run:
@@ -35,4 +39,5 @@ steps:
3539
CONFIG_DONT_QUIT: "<< parameters.dont-quit >>"
3640
CONFIG_ONLY_ON_BRANCH: "<< parameters.only-on-branch >>"
3741
CONFIG_CONFIDENCE: "<< parameters.confidence >>"
42+
CONFIG_INCLUDE_ON_HOLD: " << parameters.include-on-hold >>"
3843
command: <<include(scripts/queue.sh)>>

src/jobs/queue.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ parameters:
2929
Due to concurrency issues, how many times should we requery the pipeline list to ensure previous jobs are "pending",
3030
but not yet active. This number indicates the threshold for API returning no previous pending pipelines.
3131
Default is one confirmation, increase if you see issues.
32+
include-on-hold:
33+
type: boolean
34+
default: true
35+
description: Consider on-hold workflows waiting for approval as running and include them in the queue.
3236

3337
steps:
3438
- block_execution:
@@ -37,3 +41,4 @@ steps:
3741
dont-quit: <<parameters.dont-quit>>
3842
only-on-branch: <<parameters.only-on-branch>>
3943
confidence: <<parameters.confidence>>
44+
include-on-hold: <<parameters.include-on-hold>>

src/scripts/queue.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ fetch_pipeline_workflows(){
6666
created_at=$(jq -r '.items[] | .created_at' "${pipeline_detail}")
6767
debug "Pipeline's workflow was created at: ${created_at}"
6868
done
69-
jq -s '[.[].items[] | select((.status == "running") or (.status == "created"))]' ${tmp}/pipeline-*.json > ${workflows_file}
69+
if [ "${CONFIG_INCLUDE_ON_HOLD}" == "1" ]; then
70+
active_statuses='["running","created","on_hold"]'
71+
else
72+
active_statuses='["running","created"]'
73+
jq -s '[.[].items[] | select([.status] | inside('${active_statuses}'))]' ${tmp}/pipeline-*.json > ${workflows_file}
7074
}
7175

7276
# parse workflows to fetch parmeters about this current running workflow

0 commit comments

Comments
 (0)