Skip to content
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

Rewrite rebuild actions using javascript java injection #580

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

panicking
Copy link
Contributor

First version of rebuild that includes all the job parameters. Some improvements should be done like have just one common.jelly but not clear how jelly include logic works.

Tested using gerrit-trigger

Some help is needed to clean up

@panicking panicking force-pushed the fix-rebuild-trigger branch 2 times, most recently from 5071b79 to 811b5bd Compare February 3, 2025 02:15
@panicking panicking force-pushed the fix-rebuild-trigger branch 3 times, most recently from 8f3d2ac to e9b47c3 Compare February 3, 2025 14:36
@panicking panicking force-pushed the fix-rebuild-trigger branch 3 times, most recently from f82a009 to 182417a Compare February 3, 2025 18:26
@panicking panicking force-pushed the fix-rebuild-trigger branch 3 times, most recently from f23b17b to 2049203 Compare February 3, 2025 20:48
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is looking much better, few comments but this is very close.

*/
@RequirePOST
@JavaScriptMethod
public boolean doRebuildjob() throws IOException, ExecutionException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public boolean doRebuildjob() throws IOException, ExecutionException {
public boolean doRebuild() throws IOException, ExecutionException {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -5,7 +5,13 @@ if (rebuildButton) {
event.preventDefault();
const buildUrl = `${rebuildButton.dataset.buildPath}?delay=0sec`
if (rebuildButton.dataset.parameterized === 'true') {
window.location.href = buildUrl
var rebuildAction = window[`${rebuildButton.dataset.proxyName}`];
rebuildAction.doRebuildjob(function (success) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rebuildAction.doRebuildjob(function (success) {
rebuildAction.doRebuild(function (success) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (result) {
window.hoverNotification(rebuildButton.dataset.successMessage, rebuildButton);
}
});
} else {
fetch(buildUrl, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this anymore? Couldn't we just call the same code for rebuilding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timja I move this for a new cleanup, I need to remove even data is paremeterized I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, I can do it tomorrow. Basically I need to drop data-parameterized, the function and all the old code. Let's me think about

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rebuildAction.doRebuildjob(function (success) {
var result = success.responseJSON;
if (result) {
window.hoverNotification(rebuildButton.dataset.successMessage, rebuildButton);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a future enhancement, would be good to provide a link to the scheduled build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timja you mean in the popup? I need even to think to show an error when you can't rebuild. Basically when you have a field that has a password you can't rebuild the job. I suggest to have two popup, one in green Build scheduled and one in red.

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change here is unneeded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 66 to 67
* Handles the rebuild request and redirects to parameterized
* and non parameterized build when needed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be true? It just adds a notification with the result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@panicking panicking force-pushed the fix-rebuild-trigger branch from 2049203 to 88078b8 Compare February 3, 2025 22:19
@panicking panicking force-pushed the fix-rebuild-trigger branch 2 times, most recently from a6e3eb0 to d007dba Compare February 3, 2025 22:40
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few minor cleanups then I think good to go.

@panicking panicking force-pushed the fix-rebuild-trigger branch 2 times, most recently from 69860fa to 847abd3 Compare February 3, 2025 23:18
@timja timja added the enhancement New feature or request label Feb 4, 2025
@panicking panicking force-pushed the fix-rebuild-trigger branch from 7055eab to 2e65734 Compare February 4, 2025 08:29
Fix the rebuild that includes all the job parameters.

Tested using gerrit-trigger

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
We don't need to distinguish between parameterized and non
parameterized job

We can drop some variables

Suggested-by: Tim Jacomb <timjacomb1@gmail.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
@panicking panicking force-pushed the fix-rebuild-trigger branch from baaef34 to d8e552b Compare February 4, 2025 08:45
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@timja timja merged commit 7857c96 into jenkinsci:main Feb 4, 2025
17 checks passed
@panicking panicking deleted the fix-rebuild-trigger branch February 5, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants