-
Notifications
You must be signed in to change notification settings - Fork 66
Support withCredentials on PersonalAccessToken(Impl) #113
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
base: master
Are you sure you want to change the base?
Support withCredentials on PersonalAccessToken(Impl) #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.
Minor change needed to sort the imports in order to satisfy checkstyle.
src/test/java/org/jenkinsci/plugin/gitea/credentials/PersonalAccessTokenBindingTest.java
Outdated
Show resolved
Hide resolved
Testing done: Confirmed that the Pipeline syntax snippet generator shows the correct syntax, of the form: withCredentials([giteaPersonalAccessToken(credentialsId: 'my-gitea-token', variable: 'MY_VAR')]) { // some block } Confirmed that the localized form of the variable property and the credentials property are displayed as expected. Confirmed that my sample Pipeline worked: pipeline { agent { label 'alpine' } stages { stage('Checkout') { steps { withCredentials([giteaPersonalAccessToken(credentialsId: 'gitea-token', variable: 'ABC')]) { sh 'git clone http://[email protected]:3000/mwaite/bin.git' } } } } }
The Jenkins Pipeline syntax snippet generator needs some additions to the pull request. The file src/main/resources/org/jenkinsci/plugin/gitea/credentials/PersonalAccessTokenBinding/config.jelly is needed in order to allow the generator to display the form. I've made several changes and tested my changes interactively and think that they are ready for you to consider including them in this pull request. https://github.com/MarkEWaite/gitea-plugin/tree/feature/withCredentials-support |
…ccessTokenBindingTest.java Co-authored-by: Mark Waite <[email protected]>
No need to declare the package of the script. Use the default. No need to declare the full path to the PersonalAccessTokenBinding class, let Jenkins find it by searching. Add a newline to the end of the file.
…/gitea-plugin into feature/withCredentials-support
Guidance on quoting is adapted from https://github.com/jenkinsci/credentials-binding-plugin/edit/master/README.md
…rt' into feature/withCredentials-support
The echo step is more common in Pipeline
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.
This has passed my interactive testing, works with the Pipeline syntax snippet generator, works with localized versions of the Variable and Credentials property, includes documentation, and includes automated tests that exercise the new functionality.
I'd appreciate an (optional) review from @jglick as the expert on credentials binding implementations, but I accept that he may not have time to review it. I believe this is ready to merge and release.
…rt' into feature/withCredentials-support
From a ten-second glance this looks like the wrong approach: you should rather implement |
I'm not sure if I understood your comment correctly. I used StringBinding for the implementation and adjusted PersonalAccessToken to implement StringCredentials. af1c198 is the change |
@jglick Please let me know if this change looks good to you. If so, I will incorporate it into the PR. |
If withCredentials([string(credentialsId: 'happens-to-be-gitea', variable: 'GITEA_TOKEN')]) {…} It is not really clear to my why |
Since that class has existed since 2017, I left it alone. I didn't want to do the compatibility search to see if other plugins depend on it. |
Another test case that I ran successfully, using a declarative Pipeline with the environment directive:
|
Fixes JENKINS-75582
MultiBinding
implementation for the PersonalAccessTokenImpl class PersonalAccessToken interface.Testing done
A test was introduced to run the complete pipeline and validate withCredentials, using both the full
$class
syntax and thepersonalAccessTokenId
binding.Submitter checklist