Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-73242] Don't fail organization scan if a repository errors #790

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,15 @@
continue; // ignore repos in other orgs when using GHMyself
}

try {
// We do getSource() in order to force a populate()
// populate() can sometimes fail (eg. if the repository has a DMCA),
// so if it does we skip it.
repo.getSource();
} catch (HttpException ignored) {
continue;

Check warning on line 1043 in src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 1042-1043 are not covered by tests
}

if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
witness.record(repo.getName(), false);
listener.getLogger()
Expand Down Expand Up @@ -1117,6 +1126,15 @@
repositories = org.listRepositories(100);
}
for (GHRepository repo : repositories) {
try {
// We do getSource() in order to force a populate()
// populate() can sometimes fail (eg. if the repository has a DMCA),
// so if it does we skip it.
repo.getSource();
} catch (HttpException ignored) {
continue;

Check warning on line 1135 in src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 1134-1135 are not covered by tests
}

if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
// exclude archived repositories
witness.record(repo.getName(), false);
Expand Down Expand Up @@ -1179,6 +1197,15 @@
if (user != null && repoOwner.equalsIgnoreCase(user.getLogin())) {
listener.getLogger().format("Looking up repositories of user %s%n%n", repoOwner);
for (GHRepository repo : user.listRepositories(100)) {
try {
// We do getSource() in order to force a populate()
// populate() can sometimes fail (eg. if the repository has a DMCA),
// so if it does we skip it.
repo.getSource();
} catch (HttpException ignored) {
continue;

Check warning on line 1206 in src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 1205-1206 are not covered by tests
}

if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) {
witness.record(repo.getName(), false);
listener.getLogger()
Expand Down
350 changes: 350 additions & 0 deletions src/test/resources/api/__files/body-cloudbeers-app-store-demo.json

Large diffs are not rendered by default.

332 changes: 332 additions & 0 deletions src/test/resources/api/__files/body-cloudbeers-hellonode.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"request": {
"url": "/repos/cloudbeers/app-store-demo",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "body-cloudbeers-app-store-demo.json",
"headers": {
"Server": "GitHub.com",
"Date": "Wed, 12 Jun 2024 00:09:01 GMT",
"Content-Type": "application/json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Status": "200 OK",
"X-RateLimit-Limit": "600",
"X-RateLimit-Remaining": "600",
"X-RateLimit-Reset": "1481039762",
"Cache-Control": "public, max-age=60, s-maxage=60",
"Vary": ["Accept", "Accept-Encoding"],
"ETag": "W/\"a59a6c9d309683ec22eea939ae2521e6\"",
"Last-Modified": "Wed, 07 Sep 2016 04:20:15 GMT",
"X-GitHub-Media-Type": "github.v3; format=json",
"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",
"Access-Control-Allow-Origin": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"X-Served-By": "2d7a5e35115884240089368322196939",
"X-GitHub-Request-Id": "98B4:3BBEBD:9BEC1D:1015A96:6668E71D"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"request": {
"url": "/repos/cloudbeers/hellonode",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "body-cloudbeers-hellonode.json",
"headers": {
"Server": "GitHub.com",
"Date": "Wed, 12 Jun 2024 00:17:02 GMT",
"Content-Type": "application/json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Status": "200 OK",
"X-RateLimit-Limit": "600",
"X-RateLimit-Remaining": "600",
"X-RateLimit-Reset": "1495039662",
"Cache-Control": "public, max-age=60, s-maxage=60",
"Vary": ["Accept", "Accept-Encoding"],
"ETag": "W/\"a59a6c9d309683ec22eea939ae2521e6\"",
"Last-Modified": "Sat, 05 Nov 2016 06:52:02 GMT",
"X-GitHub-Media-Type": "github.v3; format=json",
"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",
"Access-Control-Allow-Origin": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"X-Served-By": "2d7a5e35115884240089368322196939",
"X-GitHub-Request-Id": "8AE8:1DC2D0:BAF884:13636A2:6668E8FE"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"request": {
"url": "/repos/cloudbeers/pipeline-model-definition-plugin",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "body-cloudbeers-pipeline-model-definition-plugin.json",
"headers": {
"Server": "GitHub.com",
"Date": "Wed, 12 Jun 2024 01:16:15 GMT",
"Content-Type": "application/json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Status": "200 OK",
"X-RateLimit-Limit": "600",
"X-RateLimit-Remaining": "600",
"X-RateLimit-Reset": "1495039662",
"Cache-Control": "public, max-age=60, s-maxage=60",
"Vary": ["Accept", "Accept-Encoding"],
"ETag": "W/\"a59a6c9d309683ec22eea939ae2521e6\"",
"Last-Modified": "Mon, 07 Nov 2016 16:21:08 GMT",
"X-GitHub-Media-Type": "github.v3; format=json",
"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",
"Access-Control-Allow-Origin": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"X-Served-By": "2d7a5e35115884240089368322196939",
"X-GitHub-Request-Id": "DB5C:2FAD06:FBFFAF:1A2FE8D:6668F6DF"
}
}
}
Loading