Skip to content

Commit 1a3df29

Browse files
committed
Prevent duplication of issues created by CI automation
This is done by checking for existing issues only in the milestone corresponding to the current branch. For issues, the milestone is assigned at the time of issue creation. For PRs, since the branch is different the milestone can be derived from that while triaging the issue. Closes gh-20680
1 parent d5a3310 commit 1a3df29

7 files changed

+16
-5
lines changed

ci/pipeline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ jobs:
161161
GITHUB_PASSWORD: ((github-password))
162162
GITHUB_USERNAME: ((github-username))
163163
JDK_VERSION: java8
164+
MILESTONE: ((branch))
164165
image: spring-boot-ci-image
165166
- task: detect-jdk11-update
166167
file: git-repo/ci/tasks/detect-jdk-updates.yml
@@ -170,6 +171,7 @@ jobs:
170171
GITHUB_PASSWORD: ((github-password))
171172
GITHUB_USERNAME: ((github-username))
172173
JDK_VERSION: java11
174+
MILESTONE: ((branch))
173175
image: spring-boot-ci-image
174176
- name: detect-ubuntu-image-updates
175177
plan:
@@ -185,6 +187,7 @@ jobs:
185187
GITHUB_ORGANIZATION: spring-projects
186188
GITHUB_PASSWORD: ((github-password))
187189
GITHUB_USERNAME: ((github-username))
190+
MILESTONE: ((branch))
188191
image: spring-boot-ci-image
189192
- name: detect-docker-updates
190193
plan:
@@ -199,6 +202,7 @@ jobs:
199202
params:
200203
GITHUB_REPO: spring-boot
201204
GITHUB_ORGANIZATION: spring-projects
205+
MILESTONE: ((branch))
202206
image: spring-boot-ci-image
203207
- put: git-repo-ci-docker
204208
params:

ci/scripts/detect-docker-updates.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
latest_version=$(curl -I -s https://github.com/docker/docker-ce/releases/latest | grep "location:" | awk '{n=split($0, parts, "/"); print substr(parts[n],2);}' | awk '{$1=$1;print}' | tr -d '\r' | tr -d '\n' )
44
title_prefix="Upgrade CI to Docker"
55

6-
existing_upgrade_issues=$( curl -s https://api.github.com/repos/spring-projects/spring-boot/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster | jq -c --arg TITLE_PREFIX "$title_prefix" '.[] | select(.pull_request != null) | select(.title | startswith($TITLE_PREFIX))' )
6+
milestone_number=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones\?state\=open | jq -c --arg MILESTONE "$MILESTONE" '.[] | select(.title==$MILESTONE)' | jq -r '.number')
7+
8+
existing_upgrade_issues=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster\&milestone\=${milestone_number} | jq -c --arg TITLE_PREFIX "$title_prefix" '.[] | select(.pull_request != null) | select(.title | startswith($TITLE_PREFIX))' )
79

810
if [[ ${existing_upgrade_issues} = "" ]]; then
911
git clone git-repo git-repo-updated > /dev/null

ci/scripts/detect-jdk-updates.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ if [[ $current = $latest ]]; then
2424
exit 0;
2525
fi
2626

27-
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
27+
milestone_number=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones\?state\=open | jq -c --arg MILESTONE "$MILESTONE" '.[] | select(.title==$MILESTONE)' | jq -r '.number')
28+
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster\&milestone\=${milestone_number} )
2829
existing_jdk_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
2930

3031
if [[ ${existing_jdk_issues} = "" ]]; then
3132
curl \
3233
-s \
3334
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
3435
-H "Content-type:application/json" \
35-
-d "{\"title\":\"${ISSUE_TITLE}\",\"body\": \"${latest}\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
36+
-d "{\"title\":\"${ISSUE_TITLE}\",\"milestone\":\"${milestone_number}\",\"body\": \"${latest}\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
3637
-f \
3738
-X \
3839
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues" > /dev/null || { echo "Failed to create issue" >&2; exit 1; }

ci/scripts/detect-ubuntu-image-updates.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ if [[ $current = $latest ]]; then
1111
exit 0;
1212
fi
1313

14-
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
14+
milestone_number=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones\?state\=open | jq -c --arg MILESTONE "$MILESTONE" '.[] | select(.title==$MILESTONE)' | jq -r '.number')
15+
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster\&milestone\=${milestone_number} )
1516
existing_upgrade_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
1617

1718
if [[ ${existing_upgrade_issues} = "" ]]; then
1819
curl \
1920
-s \
2021
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
2122
-H "Content-type:application/json" \
22-
-d "{\"title\":\"${ISSUE_TITLE}\",\"body\": \"Upgrade to ubuntu:${ubuntu}-${latest}\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
23+
-d "{\"title\":\"${ISSUE_TITLE}\",\"milestone\":\"${milestone_number}\",\"body\": \"Upgrade to ubuntu:${ubuntu}-${latest}\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
2324
-f \
2425
-X \
2526
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues" > /dev/null || { echo "Failed to create issue" >&2; exit 1; }

ci/tasks/detect-docker-updates.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ outputs:
99
params:
1010
GITHUB_REPO:
1111
GITHUB_ORGANIZATION:
12+
MILESTONE:
1213
run:
1314
path: git-repo/ci/scripts/detect-docker-updates.sh

ci/tasks/detect-jdk-updates.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ params:
88
GITHUB_PASSWORD:
99
GITHUB_USERNAME:
1010
JDK_VERSION:
11+
MILESTONE:
1112
run:
1213
path: git-repo/ci/scripts/detect-jdk-updates.sh

ci/tasks/detect-ubuntu-image-updates.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ params:
77
GITHUB_ORGANIZATION:
88
GITHUB_PASSWORD:
99
GITHUB_USERNAME:
10+
MILESTONE:
1011
run:
1112
path: git-repo/ci/scripts/detect-ubuntu-image-updates.sh

0 commit comments

Comments
 (0)