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

Replace Prototype.js with native JavaScript #185

Merged
merged 1 commit into from May 11, 2023

Conversation

basil
Copy link
Member

@basil basil commented May 10, 2023

See JENKINS-70906. Jenkins core currently uses Prototype 1.7, released on November 15, 2010. The latest version is Prototype 1.7.3, released on September 22, 2015. When an attempt was made to upgrade to 1.7.3 in 2018 in JENKINS-49319, the change had to be reverted. Since this library has been unmaintained for the past 8 years, this PR removes any usages of it in favor of native JavaScript APIs. To test this, I instrumented the code with

diff --git a/src/test/java/hudson/plugins/copyartifact/monitor/LegacyJobConfigMigrationMonitorMigrationTest.java b/src/test/java/hudson/plugins/copyartifact/monitor/LegacyJobConfigMigrationMonitorMigrationTest.java
index 64b7e85..6726de2 100644
--- a/src/test/java/hudson/plugins/copyartifact/monitor/LegacyJobConfigMigrationMonitorMigrationTest.java
+++ b/src/test/java/hudson/plugins/copyartifact/monitor/LegacyJobConfigMigrationMonitorMigrationTest.java
@@ -57,6 +57,7 @@ import jenkins.branch.BranchProperty;
 import jenkins.branch.BranchSource;
 import jenkins.branch.DefaultBranchPropertyStrategy;
 import jenkins.branch.NoTriggerBranchProperty;
+import jenkins.model.Jenkins;
 import jenkins.plugins.git.GitSCMSource;
 import jenkins.plugins.git.GitSampleRepoRule;
 
@@ -91,6 +92,7 @@ public class LegacyJobConfigMigrationMonitorMigrationTest {
         // anonymous cannot read jobs.
         j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
         MockAuthorizationStrategy authStrategy = new MockAuthorizationStrategy();
+        authStrategy.grant(Jenkins.ADMINISTER).everywhere().to("admin");
         j.jenkins.setAuthorizationStrategy(authStrategy);
     }
 
@@ -111,6 +113,7 @@ public class LegacyJobConfigMigrationMonitorMigrationTest {
         );
 
         j.assertBuildStatusSuccess(dst.scheduleBuild2(0));
+        j.interactiveBreak();
 
         CopyArtifactConfiguration.get().setMode(CopyArtifactCompatibilityMode.PRODUCTION);
 

and then ran mvn clean verify -Djenkins.version=2.405-SNAPSHOT -Dtest=hudson.plugins.copyartifact.monitor.LegacyJobConfigMigrationMonitorMigrationTest#migrate_freestyle_to_freestyle. I visited http://localhost:45437/jenkins/manage/administrativeMonitor/copyArtifactLegacyJobConfigMigration/manage and set breakpoints on both fetch functions. I was able to hit both breakpoints successfully.

@basil basil requested a review from a team as a code owner May 10, 2023 21:16
Copy link
Contributor

@allancth allancth left a comment

Choose a reason for hiding this comment

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

I would like to help testing the changes but I do not know where to start. Where/when are these Javascript functions called?

I am testing interactively with mvn hpi:run.

@basil
Copy link
Member Author

basil commented May 11, 2023

This pull request has already been tested, and the pull request description describes the testing that was done.

@allancth allancth merged commit ac09cb6 into jenkinsci:master May 11, 2023
13 checks passed
@MarkEWaite MarkEWaite added the enhancement New feature or improvement label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
3 participants