type() {
+ return GitHubAppCredentials.class;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "GitHub App Credentials";
+ }
+
+ @Override
+ public boolean requiresWorkspace() {
+ return false;
+ }
+ }
+}
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/config-variables.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/config-variables.jelly
new file mode 100644
index 000000000..09103ad58
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/config-variables.jelly
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-appIdVariable.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-appIdVariable.html
new file mode 100644
index 000000000..812f609e0
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-appIdVariable.html
@@ -0,0 +1,3 @@
+
+ Environment variable name for the GitHub App Id. If empty, GITHUB_APP_ID
will be used.
+
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-owner.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-owner.html
new file mode 100644
index 000000000..43a8234f9
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-owner.html
@@ -0,0 +1,3 @@
+
+ Input to override the default owner name configured for the given GitHub App credentials.
+
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-ownerVariable.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-ownerVariable.html
new file mode 100644
index 000000000..bdf3679dc
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-ownerVariable.html
@@ -0,0 +1,3 @@
+
+ Environment variable name for the GitHub App Owner. If empty, GITHUB_OWNER
will be used.
+
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-tokenVariable.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-tokenVariable.html
new file mode 100644
index 000000000..ad1fe7b18
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help-tokenVariable.html
@@ -0,0 +1,3 @@
+
+ Environment variable name for the GitHub token for given App. If empty, GITHUB_TOKEN
will be used.
+
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help.html
new file mode 100644
index 000000000..3423a53d0
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsBinding/help.html
@@ -0,0 +1,3 @@
+
+ Sets GitHup App Id, Token and Owner from the given in the credentials. Owner is input to override the default configured with credentials.
+
diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsAppInstallationTokenTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsAppInstallationTokenTest.java
index 814b738dc..1790be512 100644
--- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsAppInstallationTokenTest.java
+++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsAppInstallationTokenTest.java
@@ -17,8 +17,9 @@ public void testAppInstallationTokenStale() throws Exception {
long now;
now = Instant.now().getEpochSecond();
+ String owner = "test";
Secret secret = Secret.fromString("secret-token");
- token = new GitHubAppCredentials.AppInstallationToken(secret, now);
+ token = new GitHubAppCredentials.AppInstallationToken(owner, secret, now);
assertThat(token.isStale(), is(false));
assertThat(
token.getTokenStaleEpochSeconds(),
@@ -27,7 +28,7 @@ public void testAppInstallationTokenStale() throws Exception {
now = Instant.now().getEpochSecond();
token =
new GitHubAppCredentials.AppInstallationToken(
- secret, now + Duration.ofMinutes(15).getSeconds());
+ owner, secret, now + Duration.ofMinutes(15).getSeconds());
assertThat(token.isStale(), is(false));
assertThat(
token.getTokenStaleEpochSeconds(),
@@ -36,6 +37,7 @@ public void testAppInstallationTokenStale() throws Exception {
now = Instant.now().getEpochSecond();
token =
new GitHubAppCredentials.AppInstallationToken(
+ owner,
secret,
now + GitHubAppCredentials.AppInstallationToken.STALE_BEFORE_EXPIRATION_SECONDS + 2);
assertThat(token.isStale(), is(false));
@@ -46,6 +48,7 @@ public void testAppInstallationTokenStale() throws Exception {
now = Instant.now().getEpochSecond();
token =
new GitHubAppCredentials.AppInstallationToken(
+ owner,
secret,
now
+ GitHubAppCredentials.AppInstallationToken.STALE_BEFORE_EXPIRATION_SECONDS
@@ -57,7 +60,7 @@ public void testAppInstallationTokenStale() throws Exception {
now = Instant.now().getEpochSecond();
token =
new GitHubAppCredentials.AppInstallationToken(
- secret, now + Duration.ofMinutes(90).getSeconds());
+ owner, secret, now + Duration.ofMinutes(90).getSeconds());
assertThat(token.isStale(), is(false));
assertThat(
token.getTokenStaleEpochSeconds(),
@@ -69,7 +72,7 @@ public void testAppInstallationTokenStale() throws Exception {
GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = -10;
now = Instant.now().getEpochSecond();
- token = new GitHubAppCredentials.AppInstallationToken(secret, now);
+ token = new GitHubAppCredentials.AppInstallationToken(owner, secret, now);
assertThat(token.isStale(), is(false));
assertThat(token.getTokenStaleEpochSeconds(), equalTo(now + 1));