Repository navigation
Extension point to contextualize credentials by URL - #4001
Conversation
|
@MarkEWaite @dwnusbaum what do you think about an API like this? Obviously it is missing Javadoc, could be While I have tested a usage in the Origin branch source plugin, the more important target by far is the GitHub branch source plugin. As discussed in the linked issue, currently you are advised to use an inherently less-secure mode of GitHub App credentials if you want to use the App to check out Pipeline Groovy libraries. This is because the ultimate call to |
|
I like the idea very much. It could also be useful in some other contexts where a credential needs to be scoped to a specific git repository. The idea for the other contexts is not yet fully formed in my mind, but @mikecirioli and I have been discussing a case where something like this might be a real help. |
|
OK, let me clean up the API. I will definitely update the proposed usage in |
|
I don't quite follow the impl in jenkinsci/cursor-origin-branch-source-plugin#31. It looks like any clone for a repo in the org would get a repo-specific token, but there's no check about whether that repo should be allowed to be cloned or not. If so, then this doesn't address the same issue as jenkinsci/github-branch-source-plugin#1456, since it seems like anyone with write access to a repo could use the If you have not already seen it, https://www.jenkins.io/doc/book/security/securing-org-folders-and-multibranch-pipelines describes the general class of issues we were trying to fix with the (Maybe I misunderstand, and you have to use |
So long as the app is installed on that repo, yes. Otherwise the token request would fail (or produce an invalid token).
Well, generally, ability to write & run Pipeline script in a job to which the credential is made accessible.
Yes. The resulting token would be r/o and scoped to the selected repo. I can research whether it is possible to distinguish this case from the others. The credential class has only very indirect clues as to how it is being used:
I had not, only the |
|
@dwnusbaum I think I addressed the problem you found in jenkinsci/cursor-origin-branch-source-plugin#31, at the cost of no longer simplifying the impl as much: I still need an optional dep to reimplement some of the logic of |
|
@jglick Yes from a quick look I think that the |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The implementation passes nullable URLs to a non-null API, accepts unsupported replacement credentials, and lacks integration tests.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Adds a beta extension point for contextualizing Git credentials using build and repository URL context.
Changes:
- Defines
GitCredentialContextualizer. - Invokes contextualizers during
GitSCMcredential lookup.
| File | Description |
|---|---|
GitCredentialContextualizer.java |
Defines the contextualization API. |
GitSCM.java |
Applies contextualizers to checkout credentials. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
jenkinsci/cursor-origin-branch-source-plugin#31 is still blocked waiting for this. I have not had time to check whether |
|
Thanks @MarkEWaite! I guess this plugin is still not using CD; what sort of release schedule do you use? Seems like every couple months or so? |
I'll likely release this week. I release when I feel there are enough changes to justify a release. In this case, there are several bug fixes and this enhancement that seem like a good fit for a release. I need to run the release candidate through the plugin BOM just to be sure that it has not created any surprises. That should be possible this week. |
|
Included in git plugin release 5.11.0 |


Alternative to jenkinsci/credentials-plugin#1088, for testing in jenkinsci/cursor-origin-branch-source-plugin#28.