Skip to content

Commit 4ddc61a

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 <solonovamax@12oclockpoint.com>
1 parent 50351eb commit 4ddc61a

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
@@ -1034,6 +1034,15 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru
10341034
continue; // ignore repos in other orgs when using GHMyself
10351035
}
10361036

1037+
try {
1038+
// We do getSource() in order to force a populate()
1039+
// populate() can sometimes fail (eg. if the repository has a DMCA),
1040+
// so if it does we skip it.
1041+
repo.getSource();
1042+
} catch (HttpException ignored) {
1043+
continue;
1044+
}
1045+
10371046
if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
10381047
witness.record(repo.getName(), false);
10391048
listener.getLogger()
@@ -1117,6 +1126,15 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru
11171126
repositories = org.listRepositories(100);
11181127
}
11191128
for (GHRepository repo : repositories) {
1129+
try {
1130+
// We do getSource() in order to force a populate()
1131+
// populate() can sometimes fail (eg. if the repository has a DMCA),
1132+
// so if it does we skip it.
1133+
repo.getSource();
1134+
} catch (HttpException ignored) {
1135+
continue;
1136+
}
1137+
11201138
if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
11211139
// exclude archived repositories
11221140
witness.record(repo.getName(), false);
@@ -1179,6 +1197,15 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru
11791197
if (user != null && repoOwner.equalsIgnoreCase(user.getLogin())) {
11801198
listener.getLogger().format("Looking up repositories of user %s%n%n", repoOwner);
11811199
for (GHRepository repo : user.listRepositories(100)) {
1200+
try {
1201+
// We do getSource() in order to force a populate()
1202+
// populate() can sometimes fail (eg. if the repository has a DMCA),
1203+
// so if it does we skip it.
1204+
repo.getSource();
1205+
} catch (HttpException ignored) {
1206+
continue;
1207+
}
1208+
11821209
if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
11831210
witness.record(repo.getName(), false);
11841211
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)