Skip to content

Commit 6ea0e1e

Browse files
committed
[JENKINS-73242] Don't fail organization scan if a repository errors
See [JENKINS-73242](https://issues.jenkins.io/browse/JENKINS-73242). Signed-off-by: solonovamax <[email protected]>
1 parent 5b0c0ce commit 6ea0e1e

File tree

7 files changed

+1145
-0
lines changed

7 files changed

+1145
-0
lines changed

src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,15 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru
10291029
continue; // ignore repos in other orgs when using GHMyself
10301030
}
10311031

1032+
try {
1033+
// We do getSource() in order to force a populate()
1034+
// populate() can sometimes fail (eg. if the repository has a DMCA),
1035+
// so if it does we skip it.
1036+
repo.getSource();
1037+
} catch (HttpException ignored) {
1038+
continue;
1039+
}
1040+
10321041
if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
10331042
witness.record(repo.getName(), false);
10341043
listener.getLogger()
@@ -1119,6 +1128,15 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru
11191128
repositories = org.listRepositories(100);
11201129
}
11211130
for (GHRepository repo : repositories) {
1131+
try {
1132+
// We do getSource() in order to force a populate()
1133+
// populate() can sometimes fail (eg. if the repository has a DMCA),
1134+
// so if it does we skip it.
1135+
repo.getSource();
1136+
} catch (HttpException ignored) {
1137+
continue;
1138+
}
1139+
11221140
if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
11231141
// exclude archived repositories
11241142
witness.record(repo.getName(), false);
@@ -1189,6 +1207,15 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru
11891207
if (user != null && repoOwner.equalsIgnoreCase(user.getLogin())) {
11901208
listener.getLogger().format("Looking up repositories of user %s%n%n", repoOwner);
11911209
for (GHRepository repo : user.listRepositories(100)) {
1210+
try {
1211+
// We do getSource() in order to force a populate()
1212+
// populate() can sometimes fail (eg. if the repository has a DMCA),
1213+
// so if it does we skip it.
1214+
repo.getSource();
1215+
} catch (HttpException ignored) {
1216+
continue;
1217+
}
1218+
11921219
if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
11931220
witness.record(repo.getName(), false);
11941221
listener.getLogger()

src/test/resources/api/__files/body-cloudbeers-app-store-demo.json

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.

src/test/resources/api/__files/body-cloudbeers-hellonode.json

Lines changed: 332 additions & 0 deletions
Large diffs are not rendered by default.

src/test/resources/api/__files/body-cloudbeers-pipeline-model-definition-plugin.json

Lines changed: 334 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"request": {
3+
"url": "/repos/cloudbeers/app-store-demo",
4+
"method": "GET"
5+
},
6+
"response": {
7+
"status": 200,
8+
"bodyFileName": "body-cloudbeers-app-store-demo.json",
9+
"headers": {
10+
"Server": "GitHub.com",
11+
"Date": "Wed, 12 Jun 2024 00:09:01 GMT",
12+
"Content-Type": "application/json; charset=utf-8",
13+
"Transfer-Encoding": "chunked",
14+
"Status": "200 OK",
15+
"X-RateLimit-Limit": "600",
16+
"X-RateLimit-Remaining": "600",
17+
"X-RateLimit-Reset": "1481039762",
18+
"Cache-Control": "public, max-age=60, s-maxage=60",
19+
"Vary": ["Accept", "Accept-Encoding"],
20+
"ETag": "W/\"a59a6c9d309683ec22eea939ae2521e6\"",
21+
"Last-Modified": "Wed, 07 Sep 2016 04:20:15 GMT",
22+
"X-GitHub-Media-Type": "github.v3; format=json",
23+
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
24+
"Access-Control-Allow-Origin": "*",
25+
"Content-Security-Policy": "default-src 'none'",
26+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
27+
"X-Content-Type-Options": "nosniff",
28+
"X-Frame-Options": "deny",
29+
"X-XSS-Protection": "1; mode=block",
30+
"X-Served-By": "2d7a5e35115884240089368322196939",
31+
"X-GitHub-Request-Id": "98B4:3BBEBD:9BEC1D:1015A96:6668E71D"
32+
}
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"request": {
3+
"url": "/repos/cloudbeers/hellonode",
4+
"method": "GET"
5+
},
6+
"response": {
7+
"status": 200,
8+
"bodyFileName": "body-cloudbeers-hellonode.json",
9+
"headers": {
10+
"Server": "GitHub.com",
11+
"Date": "Wed, 12 Jun 2024 00:17:02 GMT",
12+
"Content-Type": "application/json; charset=utf-8",
13+
"Transfer-Encoding": "chunked",
14+
"Status": "200 OK",
15+
"X-RateLimit-Limit": "600",
16+
"X-RateLimit-Remaining": "600",
17+
"X-RateLimit-Reset": "1495039662",
18+
"Cache-Control": "public, max-age=60, s-maxage=60",
19+
"Vary": ["Accept", "Accept-Encoding"],
20+
"ETag": "W/\"a59a6c9d309683ec22eea939ae2521e6\"",
21+
"Last-Modified": "Sat, 05 Nov 2016 06:52:02 GMT",
22+
"X-GitHub-Media-Type": "github.v3; format=json",
23+
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
24+
"Access-Control-Allow-Origin": "*",
25+
"Content-Security-Policy": "default-src 'none'",
26+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
27+
"X-Content-Type-Options": "nosniff",
28+
"X-Frame-Options": "deny",
29+
"X-XSS-Protection": "1; mode=block",
30+
"X-Served-By": "2d7a5e35115884240089368322196939",
31+
"X-GitHub-Request-Id": "8AE8:1DC2D0:BAF884:13636A2:6668E8FE"
32+
}
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"request": {
3+
"url": "/repos/cloudbeers/pipeline-model-definition-plugin",
4+
"method": "GET"
5+
},
6+
"response": {
7+
"status": 200,
8+
"bodyFileName": "body-cloudbeers-pipeline-model-definition-plugin.json",
9+
"headers": {
10+
"Server": "GitHub.com",
11+
"Date": "Wed, 12 Jun 2024 01:16:15 GMT",
12+
"Content-Type": "application/json; charset=utf-8",
13+
"Transfer-Encoding": "chunked",
14+
"Status": "200 OK",
15+
"X-RateLimit-Limit": "600",
16+
"X-RateLimit-Remaining": "600",
17+
"X-RateLimit-Reset": "1495039662",
18+
"Cache-Control": "public, max-age=60, s-maxage=60",
19+
"Vary": ["Accept", "Accept-Encoding"],
20+
"ETag": "W/\"a59a6c9d309683ec22eea939ae2521e6\"",
21+
"Last-Modified": "Mon, 07 Nov 2016 16:21:08 GMT",
22+
"X-GitHub-Media-Type": "github.v3; format=json",
23+
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
24+
"Access-Control-Allow-Origin": "*",
25+
"Content-Security-Policy": "default-src 'none'",
26+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
27+
"X-Content-Type-Options": "nosniff",
28+
"X-Frame-Options": "deny",
29+
"X-XSS-Protection": "1; mode=block",
30+
"X-Served-By": "2d7a5e35115884240089368322196939",
31+
"X-GitHub-Request-Id": "DB5C:2FAD06:FBFFAF:1A2FE8D:6668F6DF"
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)