diff --git a/docs/inbound-agent.md b/docs/inbound-agent.md index fb14916c9..e9bf9c473 100644 --- a/docs/inbound-agent.md +++ b/docs/inbound-agent.md @@ -25,14 +25,8 @@ Note that the secret key will always be the same for a given agent name on the s If the secret key of an agent is compromised, do not reuse the agent name on the affected Jenkins controller. ### "Launch" button -This is the only launch mechanism that actually uses JNLP. -When properly configured and supported, clicking this button causes a JNLP file to be downloaded via the web browser and launched with Java WebStart. - -While this is the simplest mechanism it has many drawbacks. -This is an outdated technology that is being phased out. -It requires an interactive user. -If the agent terminates the user will have to click the button again. -This mechanism is not recommended, is deprecated, and may not be supported or available. +Historically there was a launch mechanism actually using JavaWebStart/JNLP (`javaws`). +This has been removed. ### Download JNLP file Another mechanism, shown in the above status page fragment, runs the agent from a script or command-line to retrieve the JNLP file. @@ -86,7 +80,6 @@ This mechanism requires a download of the `agent.jar`, as described for "Downloa Once all the prerequisite files and data have been obtained, the agent can be launched with a command like this ``` java -cp agent.jar hudson.remoting.jnlp.Main \ - -headless \ -workDir \ -direct \ -protocols JNLP4-connect \ @@ -103,8 +96,7 @@ The parameters available and the default behavior may be different between the e On a Microsoft Windows platform, you can install the agent as a Windows Service. This allows the Windows Service infrastructure to manage the process lifecycle. -To configure the agent this way, first launch the agent using one of the other mechanisms that doesn't run as headless. -In the agent GUI, select "File -> Install as a service". +GUI-based service installation has been removed. You can still use the Windows service wrapper. Additional descriptions of configuring this mechanism are located at [Installing Jenkins as a Windows service](https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+as+a+Windows+service) or [How to Install Several Windows Agents as a Service?](https://support.cloudbees.com/hc/en-us/articles/217423827-How-to-Install-Several-Windows-Slaves-as-a-Service-) ## Parameters diff --git a/pom.xml b/pom.xml index c0ad94993..eadc167ce 100644 --- a/pom.xml +++ b/pom.xml @@ -203,9 +203,6 @@ THE SOFTWARE. true ${basedir}/src/filter/resources - - ${basedir}/src/main/resources - ${basedir} @@ -249,12 +246,6 @@ THE SOFTWARE. hudson.remoting.Launcher ${project.version} - - - all-permissions - * - Jenkins Remoting Agent - true @@ -282,39 +273,6 @@ THE SOFTWARE. - - maven-jarsigner-plugin - 3.0.0 - - - ${hudson.sign.alias} - ${hudson.sign.storepass} - ${hudson.sign.keystore} - ${hudson.sign.storetype} - ${hudson.sign.providerClass} - ${hudson.sign.providerArg} - ${hudson.sign.tsa} - - ${hudson.sign.certchain} - - - - - sign - verify - - - - maven-dependency-plugin @@ -375,7 +333,7 @@ THE SOFTWARE. true - + org.codehaus.mojo build-helper-maven-plugin @@ -443,81 +401,6 @@ THE SOFTWARE. true - - debug - - - !hudson.sign.alias - - - - jenkins - ${basedir}/src/test/keystore/dummy.keystore - jenkins - - - - release - - - - maven-gpg-plugin - - - sign-artifacts - - sign - - verify - - - --pinentry-mode - loopback - - - - - - - maven-jarsigner-plugin - - - add-tsa - - - - - -tsa - http://timestamp.comodoca.com/rfc3161 - - - - - verify-signature - - verify - - verify - - true - false - true - true - - -strict - ${hudson.sign.alias} - ${hudson.sign.storepass} - ${hudson.sign.keystore} - ${hudson.sign.storetype} - ${hudson.sign.providerClass} - ${hudson.sign.providerArg} - - - - - - - jacoco diff --git a/src/main/java/hudson/remoting/Launcher.java b/src/main/java/hudson/remoting/Launcher.java index cdaef14d7..3578e3b13 100644 --- a/src/main/java/hudson/remoting/Launcher.java +++ b/src/main/java/hudson/remoting/Launcher.java @@ -555,8 +555,6 @@ public List parseJnlpArguments() throws ParserConfigurationException, SA jnlpArgs.add("-credentials"); jnlpArgs.add(agentJnlpCredentials); } - // force a headless mode - jnlpArgs.add("-headless"); return jnlpArgs; } catch (SSLHandshakeException e) { if(e.getMessage().contains("PKIX path building failed")) { diff --git a/src/main/java/hudson/remoting/jnlp/GUI.java b/src/main/java/hudson/remoting/jnlp/GUI.java deleted file mode 100644 index 26e613342..000000000 --- a/src/main/java/hudson/remoting/jnlp/GUI.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.remoting.jnlp; - -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.JPanel; -import javax.swing.JComponent; -import javax.swing.Icon; -import javax.swing.JLabel; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Dimension; - -/** - * GUI related helper code - * @author Kohsuke Kawaguchi - */ -public class GUI { - /** - * Sets to the platform native look and feel. - * - * see http://javaalmanac.com/egs/javax.swing/LookFeelNative.html - */ - public static void setUILookAndFeel() { - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (InstantiationException | ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException e) { - // Ignore error if we can't set look and feel. - } - } - - // Set up constraints so that the user supplied component and the - // background image label overlap and resize identically - private static final GridBagConstraints gbc; - - static { - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.NORTHWEST; - } - - public static JPanel wrapInBackgroundImage(JComponent component, - Icon backgroundIcon, - int verticalAlignment, - int horizontalAlignment) { - - // make the passed in swing component transparent - component.setOpaque(false); - - // create wrapper JPanel - JPanel backgroundPanel = new JPanel(new GridBagLayout()); - - // add the passed in swing component first to ensure that it is in front - backgroundPanel.add(component, gbc); - - // create a label to paint the background image - JLabel backgroundImage = new JLabel(backgroundIcon); - - // set minimum and preferred sizes so that the size of the image - // does not affect the layout size - backgroundImage.setPreferredSize(new Dimension(1,1)); - backgroundImage.setMinimumSize(new Dimension(1,1)); - - // align the image as specified. - backgroundImage.setVerticalAlignment(verticalAlignment); - backgroundImage.setHorizontalAlignment(horizontalAlignment); - - // add the background label - backgroundPanel.add(backgroundImage, gbc); - - // return the wrapper - return backgroundPanel; - } -} diff --git a/src/main/java/hudson/remoting/jnlp/GuiListener.java b/src/main/java/hudson/remoting/jnlp/GuiListener.java deleted file mode 100644 index 70bac8f21..000000000 --- a/src/main/java/hudson/remoting/jnlp/GuiListener.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.remoting.jnlp; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import hudson.remoting.EngineListener; - -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.logging.Logger; - -import static java.util.logging.Level.INFO; -import static java.util.logging.Level.SEVERE; - -/** - * {@link EngineListener} implementation that shows GUI. - */ -public final class GuiListener implements EngineListener { - public final MainDialog frame; - - public GuiListener() { - GUI.setUILookAndFeel(); - frame = new MainDialog(); - frame.setVisible(true); - } - - @Override - public void status(final String msg) { - status(msg,null); - } - - @Override - public void status(final String msg, final Throwable t) { - SwingUtilities.invokeLater(() -> { - frame.status(msg); - if(t!=null) - LOGGER.log(INFO, msg, t); - }); - } - - @Override - public void error(final Throwable t) { - SwingUtilities.invokeLater(new Runnable() { - @Override - @SuppressFBWarnings(value = {"DM_EXIT", "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE"}, justification = "This is an error handler for GUI, exit is valid. Used to show errors to administrator when run with GUI.") - public void run() { - LOGGER.log(SEVERE, t.getMessage(), t); - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - JOptionPane.showMessageDialog( - frame,sw.toString(),"Error", - JOptionPane.ERROR_MESSAGE); - System.exit(-1); - } - }); - } - - @Override - public void onDisconnect() { - // discard all the menu items that might have been added by the controller. - SwingUtilities.invokeLater(frame::resetMenuBar); - } - - @Override - public void onReconnect() { - } - - private static final Logger LOGGER = Logger.getLogger(GuiListener.class.getName()); -} diff --git a/src/main/java/hudson/remoting/jnlp/Main.java b/src/main/java/hudson/remoting/jnlp/Main.java index dbf3943be..e7a0e3a40 100644 --- a/src/main/java/hudson/remoting/jnlp/Main.java +++ b/src/main/java/hudson/remoting/jnlp/Main.java @@ -57,7 +57,7 @@ import static java.util.logging.Level.WARNING; /** - * Entry point to JNLP agent. + * Entry point to pseudo-JNLP agent. * *

* See also {@code jenkins-agent.jnlp.jelly} in the core. @@ -72,10 +72,10 @@ public class Main { "in which case the missing portion will be auto-configured like the default behavior") public String tunnel; + @Deprecated @Option(name="-headless", - usage="Run agent in headless mode, without GUI") - public boolean headlessMode = Boolean.getBoolean("hudson.agent.headless") - || Boolean.getBoolean("hudson.webstart.headless"); + usage="(deprecated; now always headless)") + public boolean headlessMode; @Option(name="-url", usage="Specify the Jenkins root URLs to connect to.") @@ -246,17 +246,6 @@ public static void main(String[] args) throws IOException, InterruptedException * Main without the argument handling. */ public static void _main(String[] args) throws IOException, InterruptedException, CmdLineException { - // TODO skip this on Java 17+ (e.g. io.jenkins.lib.versionnumber.JavaSpecificationVersion) as it prints a warning - // otherwise needed for JavaWebStart agents (JENKINS-67000) - try { - System.setSecurityManager(null); - } catch (SecurityException e) { - // ignore - } - - // if we run in Mac, put the menu bar where the user expects it - System.setProperty("apple.laf.useScreenMenuBar", "true"); - Main m = new Main(); CmdLineParser p = new CmdLineParser(m); p.parseArgument(args); @@ -301,7 +290,7 @@ public Engine createEngine() { String agentName = args.get(1); LOGGER.log(INFO, "Setting up agent: {0}", agentName); Engine engine = new Engine( - headlessMode ? new CuiListener() : new GuiListener(), + new CuiListener(), urls, args.get(0), agentName, directConnection, instanceIdentity, new HashSet<>(protocols)); engine.setWebSocket(webSocket); if(webSocketHeaders!=null) @@ -417,10 +406,6 @@ public Engine createEngine() { * {@link EngineListener} implementation that sends output to {@link Logger}. */ private static final class CuiListener implements EngineListener { - private CuiListener() { - LOGGER.info("Jenkins agent is running in headless mode."); - } - @Override public void status(String msg, Throwable t) { LOGGER.log(INFO,msg,t); diff --git a/src/main/java/hudson/remoting/jnlp/MainDialog.java b/src/main/java/hudson/remoting/jnlp/MainDialog.java deleted file mode 100644 index 9ac135bc7..000000000 --- a/src/main/java/hudson/remoting/jnlp/MainDialog.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.remoting.jnlp; - -import edu.umd.cs.findbugs.annotations.CheckForNull; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import hudson.remoting.Engine; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.HeadlessException; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.WindowConstants; - -/** - * Main window for JNLP agent. - * - * @author Kohsuke Kawaguchi - */ -public class MainDialog extends JFrame { - - private MainMenu mainMenu; - private final JLabel statusLabel; - - @SuppressFBWarnings( - value = { - "UI_INHERITANCE_UNSAFE_GETRESOURCE", - "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR" - }, - justification = "We allow overriding this resource. Just in case") - public MainDialog() throws HeadlessException { - super("Jenkins agent"); - - ImageIcon background = new ImageIcon(getClass().getResource("title.png")); - - JPanel foregroundPanel = new JPanel(new BorderLayout(10, 10)); - foregroundPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); - foregroundPanel.setOpaque(false); - - statusLabel = new JLabel("",JLabel.TRAILING); - foregroundPanel.add(statusLabel, BorderLayout.CENTER); - - setContentPane(GUI.wrapInBackgroundImage(foregroundPanel, background,JLabel.BOTTOM,JLabel.LEADING)); - resetMenuBar(); - - pack(); - - setSize(new Dimension(250,150)); - getContentPane().setBackground(Color.WHITE); - - setLocationByPlatform(true); - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - } - - /** - * Gets the main menu of this window, so that the caller can add - * additional menu items. - * - * @return never null. - */ - public MainMenu getMainMenu() { - return mainMenu; - } - - public void resetMenuBar() { - mainMenu = new MainMenu(this); - if(mainMenu.getComponentCount()>0) { - setJMenuBar(mainMenu); - mainMenu.commit(); - } else { - setJMenuBar(null); - if(isVisible()) - setVisible(true); // work around for paint problem. see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4949810 - } - } - - public void status(String msg) { - statusLabel.setText(msg); - } - - /** - * If the current JVM runs a {@link MainDialog} as a JNLP agent, - * return its reference, otherwise {@code null}. - */ - @CheckForNull - public static MainDialog get() { - Engine e = Engine.current(); - if(e==null) return null; - if (!(e.listener instanceof GuiListener)) return null; - return ((GuiListener) e.listener).frame; - } -} diff --git a/src/main/java/hudson/remoting/jnlp/MainMenu.java b/src/main/java/hudson/remoting/jnlp/MainMenu.java deleted file mode 100644 index b1260c034..000000000 --- a/src/main/java/hudson/remoting/jnlp/MainMenu.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.remoting.jnlp; - -import java.awt.event.KeyEvent; - -import javax.swing.JMenu; -import javax.swing.JMenuBar; - -/** - * Main menu of {@link MainDialog}. - * - * @author Kohsuke Kawaguchi - */ -public final class MainMenu extends JMenuBar { - private final MainDialog owner; - private JMenu fileMenu; - - MainMenu(MainDialog owner) { - this.owner = owner; - } - - /** - * Obtains the file menu (and creates it if necessary), - * so that the caller can add items in this menu. - */ - public JMenu getFileMenu() { - if(fileMenu==null) { - fileMenu = new JMenu("File"); - fileMenu.setMnemonic(KeyEvent.VK_F); - add(fileMenu,0); - } - return fileMenu; - } - - /** - * Reflects the changes made in the menu objects to GUI. - */ - public void commit() { - invalidate(); - repaint(); - if(getComponentCount()>0) { - owner.setJMenuBar(this); - // work around for paint problem. see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4949810 - if(owner.isVisible()) - owner.setVisible(true); - } - } -} diff --git a/src/main/resources/hudson/remoting/jnlp/title.png b/src/main/resources/hudson/remoting/jnlp/title.png deleted file mode 100644 index f2e429eab..000000000 Binary files a/src/main/resources/hudson/remoting/jnlp/title.png and /dev/null differ diff --git a/src/spotbugs/excludeFilter.xml b/src/spotbugs/excludeFilter.xml index 250215587..5995037ec 100644 --- a/src/spotbugs/excludeFilter.xml +++ b/src/spotbugs/excludeFilter.xml @@ -44,8 +44,6 @@ - - diff --git a/src/test/keystore/dummy.keystore b/src/test/keystore/dummy.keystore deleted file mode 100644 index a353377ac..000000000 Binary files a/src/test/keystore/dummy.keystore and /dev/null differ