Skip to content

Commit

Permalink
Merge pull request #28 from jenkinsci/log-error
Browse files Browse the repository at this point in the history
Do not throw error on credential list exception
  • Loading branch information
tylrd authored Nov 9, 2020
2 parents 1d0613e + 4c7e4c6 commit b8c75ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def recentLTS = "2.222.4"
def recentLTS = "2.263"
def configurations = [
[platform: "linux", jdk: "8", jenkins: recentLTS, javaLevel: "8"],
[platform: "linux", jdk: "11", jenkins: recentLTS, javaLevel: "8"],
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</scm>

<properties>
<jenkins.version>2.222.4</jenkins.version>
<jenkins.version>2.263</jenkins.version>
<java.level>8</java.level>
<jcasc.version>1.35</jcasc.version>
<spotless.version>2.5.0</spotless.version>
Expand All @@ -57,7 +57,7 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.222.x</artifactId>
<artifactId>bom-2.263.x</artifactId>
<version>16</version>
<scope>import</scope>
<type>pom</type>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.jenkins.plugins.credentials.gcp.secretsmanager;

import com.cloudbees.plugins.credentials.CredentialsUnavailableException;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.google.api.gax.rpc.ApiException;
import com.google.cloud.secretmanager.v1.ListSecretsRequest;
Expand All @@ -16,9 +15,13 @@
import java.util.Collections;
import java.util.Map;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CredentialsSupplier implements Supplier<Collection<StandardCredentials>> {

private static final Logger LOGGER = Logger.getLogger(CredentialsSupplier.class.getName());

public static Supplier<Collection<StandardCredentials>> standard() {
return new CredentialsSupplier();
}
Expand Down Expand Up @@ -77,8 +80,8 @@ public Collection<StandardCredentials> get() {
return credentials;

} catch (IOException | ApiException e) {
throw new CredentialsUnavailableException(
"secret", Messages.couldNotRetrieveCredentialError(), e);
LOGGER.log(Level.WARNING, Messages.couldNotRetrieveCredentialError(), e);
return Collections.emptyList();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.cloudbees.plugins.credentials.CredentialsUnavailableException;
import com.google.api.gax.rpc.ApiException;
import com.google.cloud.secretmanager.v1.AccessSecretVersionResponse;
import com.google.cloud.secretmanager.v1.ProjectName;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import com.google.cloud.secretmanager.v1.SecretPayload;
import com.google.cloud.secretmanager.v1.SecretVersionName;
Expand Down Expand Up @@ -32,9 +33,10 @@ public byte[] getSecretBytes(String id) {

private SecretPayload getPayload(String id) {
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
final ProjectName project = ProjectName.of(projectId);
final SecretVersionName secretVersionName =
SecretVersionName.newBuilder()
.setProject(projectId)
.setProject(project.getProject())
.setSecret(id)
.setSecretVersion("latest")
.build();
Expand Down

0 comments on commit b8c75ee

Please sign in to comment.