-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: adapted the [GitHubChecksPublisher] to be compatible with [Stan… #341
feat: adapted the [GitHubChecksPublisher] to be compatible with [Stan… #341
Conversation
…dardUsernameCredentials] instead of enforcing [GitHubAppCredentials] allowing full compatibility with the [github-branch-source-plugin] credentials format
Codecov Report
@@ Coverage Diff @@
## master #341 +/- ##
============================================
- Coverage 72.05% 72.02% -0.04%
Complexity 162 162
============================================
Files 16 16
Lines 526 529 +3
Branches 49 50 +1
============================================
+ Hits 379 381 +2
Misses 123 123
- Partials 24 25 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I don't think a Correct me if I'm wrong but I don't think a Can you confirm if jobs that take over 1 hour work with this functionality? Also can you add a test for this please? |
For an actual |
You may not want to get a new token on every reference but if it works might be fine. Is there a test you can add to have some coverage of this? anyone else got any thoughts? cc @XiongKezhi / @uhafner |
Thank you for jumping in @isometry and thank you @timja for raising this to my attention. As @isometry mentioned, this change aims to allow the same SCM credentials that Since vault-plugin-secrets-github is the underlying credentials source engine, I don't expect collisions between the GHA-derived token and long-running pipelines. I am taking steps to confirm that the long running jobs are not impacted with this change and will update this thread with my findings.
My intention was to keep the original functionality untouched by guaranteeing that credentials instances of the type |
possibly that a |
why can't you just let Jenkins issue the tokens like everyone else? 😄 |
I am happy to confirm that vault-plugin-secrets-github correctly handles token rotation which resolves the inherent issue of having long-running pipelines with GHA-derived tokens. |
We have too many Jenkins instances to make this viable (don't ask), and it's rather too easy to extract the contents of internal Jenkins credentials (i.e. the indefinite validity GHA private key). With the Vault plugin we've wholly externalised per-instance credential handling to a trusted system, only expose secrets with maximum 1hr validity, and achieved fully granular per-instance authorization :-) |
@timja : can you suggest an appropriate test to be implemented to unblock merge & release? The method signatures already ensure that only credentials inheriting from |
Let's go with this |
This change appears to have broken using SSH credentials with this plugin: https://issues.jenkins.io/browse/JENKINS-71510 |
I think I have an issue with this change, as when I updated to the latest GitHub Checks plugin, all jobs started trying to update the status in the public Github instead of our on-prem Enterprise GH - which caused all jobs to hang or fail! |
Found errors like this in the log:
our_orga/our_repo resides on out Github enterprise BTW: I'm not aware that we have configured credentials of a specific GitHubAppCredentials type |
@kutzi , the current implementation relies on having the user provide a Jenkins credentials object of the String apiUri = null;
if (credentials instanceof GitHubAppCredentials) {
apiUri = ((GitHubAppCredentials) credentials).getApiUri();
}
GitHub gitHub = Connector.connect(StringUtils.defaultIfBlank(apiUri, gitHubUrl),
credentials); AFAIK, it is not possible to attach this URI metadata elsewhere. The change that this PR introduces is that this plugin now allows for any credentials of the type private static final String GITHUB_URL = "https://api.github.com"; Having said this, this change shouldn't break any previously working configuration. However, currently it also only implicitly allows the usage of credentials of the
|
I didn't change anything. I just reverted the GitHub Checks plugin and restarted. Looking at the code changes, I cannot really see where the error lies, either... |
Checked the credentials again: we're not using any GitHubAppCredentials |
I think that's the issue: |
This change essentially enabled the plugin to try to publish checks for all jobs and not just those that use an GitHub App credentials. In our case, we use service users with Personal Access Tokens (see #352) which throws plenty of exceptions. |
Added support for
StandardUsernameCredentials
forgithub-branch-source-plugin
SCM credentials compatibilityAdapted the
GitHubChecksPublisher
publish
function to supportStandardUsernameCredentials
instead of always enforcing credentials of theGitHubAppCredentials
type.Whenever the selected credentials type is of the
GitHubAppCredentials
type, theApiUri
is still fetched to guarantee backwards compatibility:Note:
It is worth raising attention that all
StandardUsernameCredentials
used with this plugin should be GHA-derived tokens and should also be compatible withgithub-branch-source-plugin
.In my use-case, the vault-plugin-secrets-github is used to generate such tokens which are then consumed by the Jenkins pipelines.
Testing done
Procedure
As extracted from here, I have ran the following command to both build & run the test suite:
I have then installed the plugin (generated .hpi) via the /manage/pluginManager/advanced URL and restarted the Jenkins service to assert that the plugin was successfully installed.
Tests
SCM used:

Before change using

VaultUsernamePasswordCredentialImpl
:After change using

VaultUsernamePasswordCredentialImpl
:GitHub:

Submitter checklist