-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Jenkins Automation to Accept Command #4
Add Jenkins Automation to Accept Command #4
Conversation
Jobs are automatically created from the `CmdApplication.Accept` Command
String token = config.getString("jenkins", "token"); | ||
this.client = JenkinsClient.builder() | ||
.endPoint(url) | ||
.credentials(username + ":" + token) |
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.
Unrelated question, but should we have a dedicated account for this? I feel like it would be a bit too risky to have one of our accounts used here (Assuming a user-account is used and there isn't a bot-system in Jenkins).
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.
I agree with making a separate bot account. It'll help identify what the bot is doing and could also improve security by only providing necessary permissions (e.g. only create accounts and no delete).
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.
I like this. Hope it will work.
Not the biggest fan of a getLogger
method as it can make it more difficult knowing from where the log message came, but that's something that can be changed when necessary.
New formats based on @sgdc3's templates. Missed a few errors at the end, but it should be relatively the same. Also got confirmation that the |
Superceded in a new repository |
You used a wrong URL. Corrected it for you :) |
Depends on #1 being merged.
This PR uses the jenkins-rest Java API to create a user and the job they were accepted with. The API requests a generated
config.xml
, for which I have added templates in the resources folders.The Java Documentation is outdated and lacks JavaDoc comments, so I mostly went off the REST API Documentation. I've tested the various parsing methods, but it should be tested on the CodeMC Beta bot with actual dummy parameters.
Important Note
The GitHub OAuth plugin will hook into whatever username matches their GitHub Profile. The username and project name are based on the URL the reviewer provides (e.g.
https://ci.codemc.io/job/gmitch215/job/MobChip
).Other Notes
config.xml
and aconfig.xml
from a blank project.jenkins
section in the config.url
: The Jenkins URL (https://ci.codemc.io)username
: A Jenkins Username to identify the bottoken
: An API Token with necessary permissions (can also be a GitHub access token from an admin)freestyle
boolean parameter to the accept command that reviewers will need to input depending on the type of project. The description says that "freestyle" is defined as a non-maven project, similar to what the docs specify in making a new project.