diff --git a/core/src/main/java/hudson/cli/SessionIdCommand.java b/core/src/main/java/hudson/cli/SessionIdCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..5a38f489228d42435a8c2358ca28e54c36f5d100 --- /dev/null +++ b/core/src/main/java/hudson/cli/SessionIdCommand.java @@ -0,0 +1,24 @@ +package hudson.cli; + +import hudson.Extension; +import jenkins.model.Jenkins; + +/** + * Prints the current session ID number (that changes for every run) + * to allow clients to reliably wait for a restart. + * + * @author Kohsuke Kawaguchi + */ +@Extension +public class SessionIdCommand extends CLICommand { + @Override + public String getShortDescription() { + return "Outputs the session ID, which changes every time Jenkins restarts"; + } + + protected int run() { + stdout.println(Jenkins.SESSION_HASH); + return 0; + } +} +