-
Notifications
You must be signed in to change notification settings - Fork 158
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-69081] Track credential usage #113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me. Credential use tracking is a nice feature and this makes it even more effective.
@kozell I wanted to test this pull request interactively. Unfortunately, I can't find any examples that use a credential in Pipeline. I don't understand the instructions in the documentation that talk about a centrally configured credential or authentication. My attempts to configure one have failed. Can you provide some more guidance how I could test credentials with http_request? I've tried and the snippet generator never offers a credential ID httpRequest httpMode: 'POST', url: 'https://github.com/MarkEWaite/tasks.git' |
I believe that I have created a basic example that illustrates the technique. The script looks like this:
|
The example worked. With the current release of http_request plugin, the use of the credential is not tracked. With the pre-release built from this pull request, I can see the credential was used by that job. This pull request is ready to merge and release. It would be nice to include documentation and examples that show how to use a credential with the httpRequest Pipeline step, but that documentation could be done in a separate pull request. It does not need to block the merge and release of this improvement. |
I've placed a verification helper into a repository that I use to check that various behaviors are unchanged. See the Jenkinsfile in the JENKINS-69081 branch for the example |
I added an example to the README in 91c1b5a |
Excellent, thank you for testing! |
The test generates null pointer exceptions in the stapler code with the default Jenkins version used for tests. Whe the plugin requires a modern Jenkins version like 2.332.4 or 2.346.3 or 2.361.1, it will need to have a test dependency added for the javax mail api plugin. Derived from the git plugin credentials tracking test.
@kozell I've pushed a test that asserts the credential tracking is working as expected. I was able to borrow most of the implementation from the git plugin The 2.249.1 Jenkins version that is used as the minimum version for the plugin has a null pointer exception that the test reports. The null pointer exception does not prevent the test from completing its assigned tasks, but the message is distracting. When the plugin updates its minimum Jenkins version to 2.332.4 or newer, it will need the addition of the java mail api plugin as a test dependency. The test passes with 2.346.3, 2.361.1, and 2.371. I think this is ready to merge and release once the CI confirms the tests pass. |
All right, now we just need someone who can merge :-) |
The http-request plugin needs a new release to deliver the features and bug fixes that have accumulated since its last release in Aug 2022. Some of those new features and bug fixes include: * Require Jenkins 2.361.4 as minimum Jenkins version (jenkinsci/http-request-plugin#128) * JENKINS-69081 - Track credential usage (jenkinsci/http-request-plugin#113) * JENKINS-69155 - Snapshot authentication credentials (jenkinsci/http-request-plugin#111) * Upgrade HtmlUnit from 2.x to 3.x (jenkinsci/http-request-plugin#148) Documentation improvements include: * Improve feature descriptions in documentation (jenkinsci/http-request-plugin#141) * Add URL details as part of the exception (jenkinsci/http-request-plugin#74) * Add a response header example to documentation (jenkinsci/http-request-plugin#133) * rewording of abstract section (jenkinsci/http-request-plugin#130) * Drop redundant part of example (jenkinsci/http-request-plugin#122) Maintenance improvements include: * Remove divBasedFormLayout from jelly files (jenkinsci/http-request-plugin#149) jenkinsci/http-request-plugin#150 is the pull request that prompted this adoption request Reverts part of pull request: * jenkins-infra#2950
JENKINS-69081 Track credential usage
Calling CredentialsProvider::trackAll to track credential usage, as requested in the ticket.