Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-32273

Refactor and unify issue handling in CLI commands

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • cli, core
    • None

      TL;DR;
      The aim of this JIRA is to start unification of an issue handling in CLI commands.

      Details:
      Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as @CLIMethod or extending hudson.cli.CLICommand class.

      @CLIMethod usually returns 1 in the case an issue occurred, similar situation in hudson.cli.CLICommand returns -1 to the shell.

      There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in hudson.cli.CLICommand.

      Currently we should use this semantic in CLI:

      • 0 means All right
      • -1 means An error occurred

      Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

      Update 07-Jan-2016 (WIP):

      TODO

      • Refactor core commands to use correct exception classes
      • Update javadoc for CLICommand#run
      • Unify the handling in CLIRegisterer

      Proposed a new unified scheme of exception raising, handling, reporting and error code returning:
      Update 12-Feb-2016: - Exception -> Throwable

      Exception name Meaning Correct usage Incorrect usage Processing Return code
      CmdLineException Wrong parameter,
      input value can't be decoded etc.
      CommandDuringBuild.java
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      • print usage help
      2
      IllegalStateException Can't continue due to an incorrect
      state of Jenkins instance, job, build etc.
      CommandDuringBuild.java
      comes from Jenkins.getActiveInstance()
      none
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      4
      IllegalArgumentException Can't continue due to
      wrong input parameter (job doesn't exist etc.)
      CopyJobCommand.java
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      3
      AbortException Can't continue due to an other (rare) issue
      Note: Current usage of this exception is wrong,
      usually there should be IllegalState or CmdLine exception
      raised instead of this
      none
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      5
      AccessDeniedException Not sufficent rights for requested action comes from checkPermission() none
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      6
      BadCredentialsException Bad credentials provided via the CLI N/A N/A
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr with HASH
      • log a cause (HASH included) with INFO level
      7
      Exception
      Throwable
      Any unknown issue occurred, just to report it for the record N/A N/A
      • catch in CLICommand
      • print "\nERROR: " + general message to stderr
      • log general message + exception with WARNING level
      • print stacktrace to stderr for further investigation
      1

          [JENKINS-32273] Refactor and unify issue handling in CLI commands

          PR for the first step. This part is fully backward compatible.

          Pavel Janoušek added a comment - PR for the first step. This part is fully backward compatible.

          Effort continues with the code re-factorization of CLI commands re-implemented in CLI module already, plus fixes in their respective tests.

          If we want simplified, non-duplicated, easy to read code and in addition error/exception handling and reporting in one place, we can't be fully back-ward compatible here

          However I believe this change is worth and it is better for the future to do such an unification sooner than later.

          Pavel Janoušek added a comment - Effort continues with the code re-factorization of CLI commands re-implemented in CLI module already, plus fixes in their respective tests. If we want simplified, non-duplicated, easy to read code and in addition error/exception handling and reporting in one place, we can't be fully back-ward compatible here However I believe this change is worth and it is better for the future to do such an unification sooner than later.

          Pavel Janoušek added a comment - - edited

          During the investigation I've realized the particular exception is used differently (in completely different situation) in the different CLI commands or the very similar situation/issue is reported by raising a different exception class in the different CLI commands.

          For that reason I've created a new proposal for the unified scheme how to handle an exceptional situation/state, which exception should be raised, how it should be processed, reported and which return code should be returned back to the shell.

          Pavel Janoušek added a comment - - edited During the investigation I've realized the particular exception is used differently (in completely different situation) in the different CLI commands or the very similar situation/issue is reported by raising a different exception class in the different CLI commands. For that reason I've created a new proposal for the unified scheme how to handle an exceptional situation/state, which exception should be raised, how it should be processed, reported and which return code should be returned back to the shell.

          This sounds good to me. Some comments:

          • I do not understand how AbortException semantics fit CLI commands so I suggest to stop using it and perhaps even deprecate its use from CLICommands (print warningwhen caught?).
          • How about using different codes for different failure causes so clients can tell them apart easily?

          Oliver Gondža added a comment - This sounds good to me. Some comments: I do not understand how AbortException semantics fit CLI commands so I suggest to stop using it and perhaps even deprecate its use from CLICommands (print warningwhen caught?). How about using different codes for different failure causes so clients can tell them apart easily?

          Daniel Beck added a comment -

          Isn't -1 == 255? Typically error codes are in the low positive range…

          Daniel Beck added a comment - Isn't -1 == 255? Typically error codes are in the low positive range…

          Exit codes are seen as positive values by the waiting shell. So if you exit -1, the shell sees 255, -2 is 254, etc. Although in practice you seldom need to translate these values, it is more direct to use positive numbers when exiting. This way the program calling exit, and the shell waiting, both see the same value (1 is 1, 2 is 2, etc.).

          Also, print the error message before exiting, and print it to stderr. This way no documentation lookup is needed to relate the exit code to the error message. It is always good IMO to start the error message on a new line with something like "Error: ..." or "ERROR: ...". This way it can be grep'ed easily (grep '^Error').

          You can spend a lot of time tabulating different values of exit code for all the cases, most times in practice, exit 1 preceded by a good error message will suffice.

          Martin d'Anjou added a comment - Exit codes are seen as positive values by the waiting shell. So if you exit -1, the shell sees 255, -2 is 254, etc. Although in practice you seldom need to translate these values, it is more direct to use positive numbers when exiting. This way the program calling exit, and the shell waiting, both see the same value (1 is 1, 2 is 2, etc.). Also, print the error message before exiting, and print it to stderr. This way no documentation lookup is needed to relate the exit code to the error message. It is always good IMO to start the error message on a new line with something like "Error: ..." or "ERROR: ...". This way it can be grep'ed easily ( grep '^Error' ). You can spend a lot of time tabulating different values of exit code for all the cases, most times in practice, exit 1 preceded by a good error message will suffice.

          Daniel Beck added a comment -

          Exit codes are seen as positive values by the waiting shell. So if you exit -1, the shell sees 255, -2 is 254, etc.

          That's what I mean by -1 == 255. And I'd rather see 1,2,3,4 (what I meant by "low positive range") than 255,254,253,252.

          Daniel Beck added a comment - Exit codes are seen as positive values by the waiting shell. So if you exit -1, the shell sees 255, -2 is 254, etc. That's what I mean by -1 == 255 . And I'd rather see 1,2,3,4 (what I meant by "low positive range") than 255,254,253,252.

          Pavel Janoušek added a comment - - edited

          Proposal updated - return codes and processing.

          @Martin
          I agree that that behavior is sufficient for most cases. On the other hand, there can be a case where more precise error code analysis is helpful. If someone can only detect if something went wrong, he can use "return code !=0" (or "return code > 0") expression easily, but if we return 1 for most (probably all) error cases, additional effort on caller side would be needed - then a different error code would be welcomed.

          Pavel Janoušek added a comment - - edited Proposal updated - return codes and processing. @Martin I agree that that behavior is sufficient for most cases. On the other hand, there can be a case where more precise error code analysis is helpful. If someone can only detect if something went wrong, he can use "return code !=0" (or "return code > 0") expression easily, but if we return 1 for most (probably all) error cases, additional effort on caller side would be needed - then a different error code would be welcomed.

          Code changed in jenkins
          User: Ing. Pavel Janousek
          Path:
          core/src/main/java/hudson/cli/CLICommand.java
          http://jenkins-ci.org/commit/jenkins/253c2a6444ee9ce8503cea592e1f10a77d51f654
          Log:
          JENKINS-32273 Jenkins CLI unification of error handling and returning

          Extended exception handling and logging in CLICommand

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ing. Pavel Janousek Path: core/src/main/java/hudson/cli/CLICommand.java http://jenkins-ci.org/commit/jenkins/253c2a6444ee9ce8503cea592e1f10a77d51f654 Log: JENKINS-32273 Jenkins CLI unification of error handling and returning Extended exception handling and logging in CLICommand

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/cli/CLICommand.java
          http://jenkins-ci.org/commit/jenkins/a7a8e3081e6bbb5886aad961a4a3b514ad3e73d5
          Log:
          Merge pull request #1969 from pjanouse/JENKINS-32273

          JENKINS-32273 Jenkins CLI unification of error handling and returning

          Compare: https://github.com/jenkinsci/jenkins/compare/70edfcda1010...a7a8e3081e6b

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/cli/CLICommand.java http://jenkins-ci.org/commit/jenkins/a7a8e3081e6bbb5886aad961a4a3b514ad3e73d5 Log: Merge pull request #1969 from pjanouse/ JENKINS-32273 JENKINS-32273 Jenkins CLI unification of error handling and returning Compare: https://github.com/jenkinsci/jenkins/compare/70edfcda1010...a7a8e3081e6b

          dogfood added a comment -

          Integrated in jenkins_main_trunk #4410
          JENKINS-32273 Jenkins CLI unification of error handling and returning (Revision 253c2a6444ee9ce8503cea592e1f10a77d51f654)

          Result = UNSTABLE
          pjanouse : 253c2a6444ee9ce8503cea592e1f10a77d51f654
          Files :

          • core/src/main/java/hudson/cli/CLICommand.java

          dogfood added a comment - Integrated in jenkins_main_trunk #4410 JENKINS-32273 Jenkins CLI unification of error handling and returning (Revision 253c2a6444ee9ce8503cea592e1f10a77d51f654) Result = UNSTABLE pjanouse : 253c2a6444ee9ce8503cea592e1f10a77d51f654 Files : core/src/main/java/hudson/cli/CLICommand.java

          dogfood added a comment -

          Integrated in jenkins_2.0 #5
          JENKINS-32273 Jenkins CLI unification of error handling and returning (Revision 253c2a6444ee9ce8503cea592e1f10a77d51f654)

          Result = SUCCESS
          pjanouse : 253c2a6444ee9ce8503cea592e1f10a77d51f654
          Files :

          • core/src/main/java/hudson/cli/CLICommand.java

          dogfood added a comment - Integrated in jenkins_2.0 #5 JENKINS-32273 Jenkins CLI unification of error handling and returning (Revision 253c2a6444ee9ce8503cea592e1f10a77d51f654) Result = SUCCESS pjanouse : 253c2a6444ee9ce8503cea592e1f10a77d51f654 Files : core/src/main/java/hudson/cli/CLICommand.java

          PR for re-factored code sent.

          Pavel Janoušek added a comment - PR for re-factored code sent.

          Jesse Glick added a comment -

          IMO exit code 1 should be reserved for foreseeable, nonexceptional “failure”, with 2+ being used for true errors. See man grep for example. CC teilo

          Jesse Glick added a comment - IMO exit code 1 should be reserved for foreseeable, nonexceptional “failure”, with 2+ being used for true errors. See man grep for example. CC teilo

          jglick, what would be foreseeable, nonexceptional “failure”? Incorrect command use? Permission? Entity does not exist/can not accept given operation?

          Oliver Gondža added a comment - jglick , what would be foreseeable, nonexceptional “failure” ? Incorrect command use? Permission? Entity does not exist/can not accept given operation?

          Daniel Beck added a comment -

          IMO: New name of renamed project taken. Name of created project taken. Quieting down but Jenkins is already. Node is already marked offline.

          Daniel Beck added a comment - IMO: New name of renamed project taken. Name of created project taken. Quieting down but Jenkins is already. Node is already marked offline.

          Oliver Gondža added a comment - - edited

          I suggest to keep the cases when command is putting Jenkins into some state (computer offline, jenkins quieting down, job in view, etc.) while it already is in such state aside for now as I would like to see those idempotent and therefore return 0. (Unless we want to squeeze such change into this PR).

          I fail to come up with a definition of foreseeable failure class. Consider there is a client that calls Jenkins CLI internally, how would handling of such problems differ?

          Oliver Gondža added a comment - - edited I suggest to keep the cases when command is putting Jenkins into some state (computer offline, jenkins quieting down, job in view, etc.) while it already is in such state aside for now as I would like to see those idempotent and therefore return 0. (Unless we want to squeeze such change into this PR). I fail to come up with a definition of foreseeable failure class. Consider there is a client that calls Jenkins CLI internally, how would handling of such problems differ?

          Daniel Beck added a comment -

          I would like to see those idempotent and therefore return 0.

          Good point. Still leaves creating/renaming a job when the name is already taken. Trying to get-job a job that does not exist. Etc.

          Daniel Beck added a comment - I would like to see those idempotent and therefore return 0. Good point. Still leaves creating/renaming a job when the name is already taken. Trying to get-job a job that does not exist. Etc.

          I don't see an issue to start error return codes numbering in the above table from 2 if necessary.

          My intention is to have uniform issue handling/reporting from all CLI commands. I think the best way how we can do that is to throw appropriate exception (following above scheme) when it occurs and pass its handling/reporting to the CLICommand class itself.

          If we follow that every CLI command can on "foreseeable issue" return its own code (includes reporting), we can lost this benefit at all and return to the previous state.

          Pavel Janoušek added a comment - I don't see an issue to start error return codes numbering in the above table from 2 if necessary. My intention is to have uniform issue handling/reporting from all CLI commands. I think the best way how we can do that is to throw appropriate exception (following above scheme) when it occurs and pass its handling/reporting to the CLICommand class itself. If we follow that every CLI command can on "foreseeable issue" return its own code (includes reporting), we can lost this benefit at all and return to the previous state.

          James Nord added a comment - - edited

          @danielBeck - I suggest your example of rename not the correct use case here - basically what we are trying to say is - the command ran perfectly fine and did exactly what you asked it to - but there is nothing to report / no side effects.

          This is distinct from the command not doing what you asked due to some reason (the job you asked it to rename already exists)

          e.g. consider a fictional CLI command isJenkinsInQueitDownMode.

          to be usable by scripts you would want 2 different exit codes (but both mean the command ran ok) - 0 would be false, 1 would be true and >1 is error_something_bad_happened. Otherwise you need to output some text - and that text should be localizable for humans - which means you need to write a whole boat load of code on your script to both parse the response and generate the outpu - ie a --machine-output=true flag)

          So 1 is not an error case and it is not for "forseeable errors" - its where the CLI wants to say Hey I ran successfully but (similar to grep foo bar when bar does not contain foo.

          James Nord added a comment - - edited @danielBeck - I suggest your example of rename not the correct use case here - basically what we are trying to say is - the command ran perfectly fine and did exactly what you asked it to - but there is nothing to report / no side effects. This is distinct from the command not doing what you asked due to some reason (the job you asked it to rename already exists) e.g. consider a fictional CLI command isJenkinsInQueitDownMode . to be usable by scripts you would want 2 different exit codes (but both mean the command ran ok) - 0 would be false, 1 would be true and >1 is error_something_bad_happened. Otherwise you need to output some text - and that text should be localizable for humans - which means you need to write a whole boat load of code on your script to both parse the response and generate the outpu - ie a --machine-output=true flag) So 1 is not an error case and it is not for "forseeable errors" - its where the CLI wants to say Hey I ran successfully but (similar to grep foo bar when bar does not contain foo.

          Pavel Janoušek added a comment - - edited

          Exception isn't enough general standpoint.

          For example Java language assert code (raises java.lang.AssertionException which isn't derived from java.lang.Exception). We have to catch an unchecked exception as well, so I've changed Exception to Throwable as the most general standpoint if anything unknown goes wrong.

          Pavel Janoušek added a comment - - edited Exception isn't enough general standpoint. For example Java language assert code (raises java.lang.AssertionException which isn't derived from java.lang.Exception ). We have to catch an unchecked exception as well, so I've changed Exception to Throwable as the most general standpoint if anything unknown goes wrong.

          Code changed in jenkins
          User: Ing. Pavel Janousek
          Path:
          core/src/main/java/hudson/cli/CLICommand.java
          http://jenkins-ci.org/commit/jenkins/49d9f0e1b5872b7eea4d22c8b5edd634cc28e9f6
          Log:
          JENKINS-32273 Refactored return error codes and messages

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ing. Pavel Janousek Path: core/src/main/java/hudson/cli/CLICommand.java http://jenkins-ci.org/commit/jenkins/49d9f0e1b5872b7eea4d22c8b5edd634cc28e9f6 Log: JENKINS-32273 Refactored return error codes and messages

          Code changed in jenkins
          User: Ing. Pavel Janousek
          Path:
          core/src/main/java/hudson/cli/AddJobToViewCommand.java
          core/src/main/java/hudson/cli/BuildCommand.java
          core/src/main/java/hudson/cli/CLIAction.java
          core/src/main/java/hudson/cli/CLICommand.java
          core/src/main/java/hudson/cli/CliProtocol.java
          core/src/main/java/hudson/cli/CliProtocol2.java
          core/src/main/java/hudson/cli/ClientAuthenticationCache.java
          core/src/main/java/hudson/cli/CommandDuringBuild.java
          core/src/main/java/hudson/cli/ConsoleCommand.java
          core/src/main/java/hudson/cli/CopyJobCommand.java
          core/src/main/java/hudson/cli/CreateJobCommand.java
          core/src/main/java/hudson/cli/CreateNodeCommand.java
          core/src/main/java/hudson/cli/CreateViewCommand.java
          core/src/main/java/hudson/cli/DeleteJobCommand.java
          core/src/main/java/hudson/cli/DeleteNodeCommand.java
          core/src/main/java/hudson/cli/DeleteViewCommand.java
          core/src/main/java/hudson/cli/GroovyCommand.java
          core/src/main/java/hudson/cli/GroovyshCommand.java
          core/src/main/java/hudson/cli/HelpCommand.java
          core/src/main/java/hudson/cli/InstallPluginCommand.java
          core/src/main/java/hudson/cli/InstallToolCommand.java
          core/src/main/java/hudson/cli/ListJobsCommand.java
          core/src/main/java/hudson/cli/ListPluginsCommand.java
          core/src/main/java/hudson/cli/OnlineNodeCommand.java
          core/src/main/java/hudson/cli/ReloadJobCommand.java
          core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java
          core/src/main/java/hudson/cli/SetBuildDisplayNameCommand.java
          core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
          core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java
          core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java
          core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java
          core/src/test/java/hudson/cli/ListJobsCommandTest.java
          core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
          test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
          test/src/test/java/hudson/cli/CLIRegistererTest.java
          test/src/test/java/hudson/cli/CopyJobCommandTest.java
          test/src/test/java/hudson/cli/CreateJobCommandTest.java
          test/src/test/java/hudson/cli/CreateNodeCommandTest.java
          test/src/test/java/hudson/cli/CreateViewCommandTest.java
          test/src/test/java/hudson/cli/DeleteJobCommandTest.java
          test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
          test/src/test/java/hudson/cli/DeleteViewCommandTest.java
          test/src/test/java/hudson/cli/GetNodeCommandTest.java
          test/src/test/java/hudson/cli/GetViewCommandTest.java
          test/src/test/java/hudson/cli/OnlineNodeCommandTest.java
          test/src/test/java/hudson/cli/ReloadJobCommandTest.java
          test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java
          test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
          test/src/test/java/hudson/cli/UpdateViewCommandTest.java
          test/src/test/java/hudson/cli/ViewManipulationTest.java
          test/src/test/java/jenkins/security/Security218CliTest.java
          http://jenkins-ci.org/commit/jenkins/d5725e6d18c0bcd4a2640943eaea059f137786bc
          Log:
          JENKINS-32273 Unified an issue handling in CLI

          Re-factored all existed CLI code to follow the new proposed scheme for
          raising an exception if issue occurs, handling and reporting it.
          Unified CLIRegisterer as well.
          Fixed unit tests to follow the new scheme.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ing. Pavel Janousek Path: core/src/main/java/hudson/cli/AddJobToViewCommand.java core/src/main/java/hudson/cli/BuildCommand.java core/src/main/java/hudson/cli/CLIAction.java core/src/main/java/hudson/cli/CLICommand.java core/src/main/java/hudson/cli/CliProtocol.java core/src/main/java/hudson/cli/CliProtocol2.java core/src/main/java/hudson/cli/ClientAuthenticationCache.java core/src/main/java/hudson/cli/CommandDuringBuild.java core/src/main/java/hudson/cli/ConsoleCommand.java core/src/main/java/hudson/cli/CopyJobCommand.java core/src/main/java/hudson/cli/CreateJobCommand.java core/src/main/java/hudson/cli/CreateNodeCommand.java core/src/main/java/hudson/cli/CreateViewCommand.java core/src/main/java/hudson/cli/DeleteJobCommand.java core/src/main/java/hudson/cli/DeleteNodeCommand.java core/src/main/java/hudson/cli/DeleteViewCommand.java core/src/main/java/hudson/cli/GroovyCommand.java core/src/main/java/hudson/cli/GroovyshCommand.java core/src/main/java/hudson/cli/HelpCommand.java core/src/main/java/hudson/cli/InstallPluginCommand.java core/src/main/java/hudson/cli/InstallToolCommand.java core/src/main/java/hudson/cli/ListJobsCommand.java core/src/main/java/hudson/cli/ListPluginsCommand.java core/src/main/java/hudson/cli/OnlineNodeCommand.java core/src/main/java/hudson/cli/ReloadJobCommand.java core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java core/src/main/java/hudson/cli/SetBuildDisplayNameCommand.java core/src/main/java/hudson/cli/declarative/CLIRegisterer.java core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java core/src/test/java/hudson/cli/ListJobsCommandTest.java core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java test/src/test/groovy/hudson/cli/BuildCommandTest.groovy test/src/test/java/hudson/cli/CLIRegistererTest.java test/src/test/java/hudson/cli/CopyJobCommandTest.java test/src/test/java/hudson/cli/CreateJobCommandTest.java test/src/test/java/hudson/cli/CreateNodeCommandTest.java test/src/test/java/hudson/cli/CreateViewCommandTest.java test/src/test/java/hudson/cli/DeleteJobCommandTest.java test/src/test/java/hudson/cli/DeleteNodeCommandTest.java test/src/test/java/hudson/cli/DeleteViewCommandTest.java test/src/test/java/hudson/cli/GetNodeCommandTest.java test/src/test/java/hudson/cli/GetViewCommandTest.java test/src/test/java/hudson/cli/OnlineNodeCommandTest.java test/src/test/java/hudson/cli/ReloadJobCommandTest.java test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java test/src/test/java/hudson/cli/UpdateNodeCommandTest.java test/src/test/java/hudson/cli/UpdateViewCommandTest.java test/src/test/java/hudson/cli/ViewManipulationTest.java test/src/test/java/jenkins/security/Security218CliTest.java http://jenkins-ci.org/commit/jenkins/d5725e6d18c0bcd4a2640943eaea059f137786bc Log: JENKINS-32273 Unified an issue handling in CLI Re-factored all existed CLI code to follow the new proposed scheme for raising an exception if issue occurs, handling and reporting it. Unified CLIRegisterer as well. Fixed unit tests to follow the new scheme.

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/cli/AddJobToViewCommand.java
          core/src/main/java/hudson/cli/BuildCommand.java
          core/src/main/java/hudson/cli/CLIAction.java
          core/src/main/java/hudson/cli/CLICommand.java
          core/src/main/java/hudson/cli/CliProtocol.java
          core/src/main/java/hudson/cli/CliProtocol2.java
          core/src/main/java/hudson/cli/ClientAuthenticationCache.java
          core/src/main/java/hudson/cli/CommandDuringBuild.java
          core/src/main/java/hudson/cli/ConsoleCommand.java
          core/src/main/java/hudson/cli/CopyJobCommand.java
          core/src/main/java/hudson/cli/CreateJobCommand.java
          core/src/main/java/hudson/cli/CreateNodeCommand.java
          core/src/main/java/hudson/cli/CreateViewCommand.java
          core/src/main/java/hudson/cli/DeleteJobCommand.java
          core/src/main/java/hudson/cli/DeleteNodeCommand.java
          core/src/main/java/hudson/cli/DeleteViewCommand.java
          core/src/main/java/hudson/cli/GroovyCommand.java
          core/src/main/java/hudson/cli/GroovyshCommand.java
          core/src/main/java/hudson/cli/HelpCommand.java
          core/src/main/java/hudson/cli/InstallPluginCommand.java
          core/src/main/java/hudson/cli/InstallToolCommand.java
          core/src/main/java/hudson/cli/ListJobsCommand.java
          core/src/main/java/hudson/cli/ListPluginsCommand.java
          core/src/main/java/hudson/cli/OnlineNodeCommand.java
          core/src/main/java/hudson/cli/ReloadJobCommand.java
          core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java
          core/src/main/java/hudson/cli/SetBuildDisplayNameCommand.java
          core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
          core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java
          core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java
          core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java
          core/src/test/java/hudson/cli/ListJobsCommandTest.java
          core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
          test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
          test/src/test/java/hudson/cli/CLIRegistererTest.java
          test/src/test/java/hudson/cli/CopyJobCommandTest.java
          test/src/test/java/hudson/cli/CreateJobCommandTest.java
          test/src/test/java/hudson/cli/CreateNodeCommandTest.java
          test/src/test/java/hudson/cli/CreateViewCommandTest.java
          test/src/test/java/hudson/cli/DeleteJobCommandTest.java
          test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
          test/src/test/java/hudson/cli/DeleteViewCommandTest.java
          test/src/test/java/hudson/cli/GetNodeCommandTest.java
          test/src/test/java/hudson/cli/GetViewCommandTest.java
          test/src/test/java/hudson/cli/OnlineNodeCommandTest.java
          test/src/test/java/hudson/cli/ReloadJobCommandTest.java
          test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java
          test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
          test/src/test/java/hudson/cli/UpdateViewCommandTest.java
          test/src/test/java/hudson/cli/ViewManipulationTest.java
          test/src/test/java/jenkins/security/Security218CliTest.java
          http://jenkins-ci.org/commit/jenkins/fe41dc89ab9801c9d57713f84e650788e172e115
          Log:
          Merge pull request #1997 from pjanouse/JENKINS-32273

          JENKINS-32273 Unified an issue handling in CLI

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/cli/AddJobToViewCommand.java core/src/main/java/hudson/cli/BuildCommand.java core/src/main/java/hudson/cli/CLIAction.java core/src/main/java/hudson/cli/CLICommand.java core/src/main/java/hudson/cli/CliProtocol.java core/src/main/java/hudson/cli/CliProtocol2.java core/src/main/java/hudson/cli/ClientAuthenticationCache.java core/src/main/java/hudson/cli/CommandDuringBuild.java core/src/main/java/hudson/cli/ConsoleCommand.java core/src/main/java/hudson/cli/CopyJobCommand.java core/src/main/java/hudson/cli/CreateJobCommand.java core/src/main/java/hudson/cli/CreateNodeCommand.java core/src/main/java/hudson/cli/CreateViewCommand.java core/src/main/java/hudson/cli/DeleteJobCommand.java core/src/main/java/hudson/cli/DeleteNodeCommand.java core/src/main/java/hudson/cli/DeleteViewCommand.java core/src/main/java/hudson/cli/GroovyCommand.java core/src/main/java/hudson/cli/GroovyshCommand.java core/src/main/java/hudson/cli/HelpCommand.java core/src/main/java/hudson/cli/InstallPluginCommand.java core/src/main/java/hudson/cli/InstallToolCommand.java core/src/main/java/hudson/cli/ListJobsCommand.java core/src/main/java/hudson/cli/ListPluginsCommand.java core/src/main/java/hudson/cli/OnlineNodeCommand.java core/src/main/java/hudson/cli/ReloadJobCommand.java core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java core/src/main/java/hudson/cli/SetBuildDisplayNameCommand.java core/src/main/java/hudson/cli/declarative/CLIRegisterer.java core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java core/src/test/java/hudson/cli/ListJobsCommandTest.java core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java test/src/test/groovy/hudson/cli/BuildCommandTest.groovy test/src/test/java/hudson/cli/CLIRegistererTest.java test/src/test/java/hudson/cli/CopyJobCommandTest.java test/src/test/java/hudson/cli/CreateJobCommandTest.java test/src/test/java/hudson/cli/CreateNodeCommandTest.java test/src/test/java/hudson/cli/CreateViewCommandTest.java test/src/test/java/hudson/cli/DeleteJobCommandTest.java test/src/test/java/hudson/cli/DeleteNodeCommandTest.java test/src/test/java/hudson/cli/DeleteViewCommandTest.java test/src/test/java/hudson/cli/GetNodeCommandTest.java test/src/test/java/hudson/cli/GetViewCommandTest.java test/src/test/java/hudson/cli/OnlineNodeCommandTest.java test/src/test/java/hudson/cli/ReloadJobCommandTest.java test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java test/src/test/java/hudson/cli/UpdateNodeCommandTest.java test/src/test/java/hudson/cli/UpdateViewCommandTest.java test/src/test/java/hudson/cli/ViewManipulationTest.java test/src/test/java/jenkins/security/Security218CliTest.java http://jenkins-ci.org/commit/jenkins/fe41dc89ab9801c9d57713f84e650788e172e115 Log: Merge pull request #1997 from pjanouse/ JENKINS-32273 JENKINS-32273 Unified an issue handling in CLI

          dogfood added a comment -

          Integrated in jenkins_main_trunk #4458
          JENKINS-32273 Refactored return error codes and messages (Revision 49d9f0e1b5872b7eea4d22c8b5edd634cc28e9f6)
          JENKINS-32273 Unified an issue handling in CLI (Revision d5725e6d18c0bcd4a2640943eaea059f137786bc)

          Result = SUCCESS
          pjanouse : 49d9f0e1b5872b7eea4d22c8b5edd634cc28e9f6
          Files :

          • core/src/main/java/hudson/cli/CLICommand.java

          pjanouse : d5725e6d18c0bcd4a2640943eaea059f137786bc
          Files :

          • test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java
          • core/src/main/java/hudson/cli/DeleteNodeCommand.java
          • core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java
          • test/src/test/java/hudson/cli/UpdateViewCommandTest.java
          • core/src/test/java/hudson/cli/ListJobsCommandTest.java
          • core/src/main/java/hudson/cli/GroovyCommand.java
          • core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java
          • test/src/test/java/hudson/cli/GetViewCommandTest.java
          • test/src/test/java/hudson/cli/CopyJobCommandTest.java
          • core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
          • core/src/main/java/hudson/cli/InstallPluginCommand.java
          • core/src/main/java/hudson/cli/CommandDuringBuild.java
          • test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
          • test/src/test/java/hudson/cli/ViewManipulationTest.java
          • test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
          • test/src/test/java/hudson/cli/CreateNodeCommandTest.java
          • test/src/test/java/hudson/cli/GetNodeCommandTest.java
          • core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java
          • core/src/main/java/hudson/cli/ListJobsCommand.java
          • core/src/main/java/hudson/cli/InstallToolCommand.java
          • core/src/main/java/hudson/cli/BuildCommand.java
          • test/src/test/java/hudson/cli/CreateViewCommandTest.java
          • core/src/main/java/hudson/cli/ConsoleCommand.java
          • test/src/test/java/hudson/cli/CreateJobCommandTest.java
          • core/src/main/java/hudson/cli/ClientAuthenticationCache.java
          • core/src/main/java/hudson/cli/SetBuildDisplayNameCommand.java
          • core/src/main/java/hudson/cli/GroovyshCommand.java
          • core/src/main/java/hudson/cli/CreateJobCommand.java
          • core/src/main/java/hudson/cli/DeleteViewCommand.java
          • test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
          • core/src/main/java/hudson/cli/CliProtocol.java
          • core/src/main/java/hudson/cli/CLICommand.java
          • test/src/test/java/jenkins/security/Security218CliTest.java
          • core/src/main/java/hudson/cli/ListPluginsCommand.java
          • core/src/main/java/hudson/cli/CLIAction.java
          • core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
          • core/src/main/java/hudson/cli/ReloadJobCommand.java
          • core/src/main/java/hudson/cli/HelpCommand.java
          • test/src/test/java/hudson/cli/CLIRegistererTest.java
          • test/src/test/java/hudson/cli/OnlineNodeCommandTest.java
          • core/src/main/java/hudson/cli/OnlineNodeCommand.java
          • core/src/main/java/hudson/cli/AddJobToViewCommand.java
          • core/src/main/java/hudson/cli/CliProtocol2.java
          • core/src/main/java/hudson/cli/CreateNodeCommand.java
          • test/src/test/java/hudson/cli/DeleteJobCommandTest.java
          • core/src/main/java/hudson/cli/CreateViewCommand.java
          • test/src/test/java/hudson/cli/DeleteViewCommandTest.java
          • core/src/main/java/hudson/cli/DeleteJobCommand.java
          • core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java
          • test/src/test/java/hudson/cli/ReloadJobCommandTest.java
          • core/src/main/java/hudson/cli/CopyJobCommand.java

          dogfood added a comment - Integrated in jenkins_main_trunk #4458 JENKINS-32273 Refactored return error codes and messages (Revision 49d9f0e1b5872b7eea4d22c8b5edd634cc28e9f6) JENKINS-32273 Unified an issue handling in CLI (Revision d5725e6d18c0bcd4a2640943eaea059f137786bc) Result = SUCCESS pjanouse : 49d9f0e1b5872b7eea4d22c8b5edd634cc28e9f6 Files : core/src/main/java/hudson/cli/CLICommand.java pjanouse : d5725e6d18c0bcd4a2640943eaea059f137786bc Files : test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java core/src/main/java/hudson/cli/DeleteNodeCommand.java core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java test/src/test/java/hudson/cli/UpdateViewCommandTest.java core/src/test/java/hudson/cli/ListJobsCommandTest.java core/src/main/java/hudson/cli/GroovyCommand.java core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java test/src/test/java/hudson/cli/GetViewCommandTest.java test/src/test/java/hudson/cli/CopyJobCommandTest.java core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java core/src/main/java/hudson/cli/InstallPluginCommand.java core/src/main/java/hudson/cli/CommandDuringBuild.java test/src/test/groovy/hudson/cli/BuildCommandTest.groovy test/src/test/java/hudson/cli/ViewManipulationTest.java test/src/test/java/hudson/cli/DeleteNodeCommandTest.java test/src/test/java/hudson/cli/CreateNodeCommandTest.java test/src/test/java/hudson/cli/GetNodeCommandTest.java core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java core/src/main/java/hudson/cli/ListJobsCommand.java core/src/main/java/hudson/cli/InstallToolCommand.java core/src/main/java/hudson/cli/BuildCommand.java test/src/test/java/hudson/cli/CreateViewCommandTest.java core/src/main/java/hudson/cli/ConsoleCommand.java test/src/test/java/hudson/cli/CreateJobCommandTest.java core/src/main/java/hudson/cli/ClientAuthenticationCache.java core/src/main/java/hudson/cli/SetBuildDisplayNameCommand.java core/src/main/java/hudson/cli/GroovyshCommand.java core/src/main/java/hudson/cli/CreateJobCommand.java core/src/main/java/hudson/cli/DeleteViewCommand.java test/src/test/java/hudson/cli/UpdateNodeCommandTest.java core/src/main/java/hudson/cli/CliProtocol.java core/src/main/java/hudson/cli/CLICommand.java test/src/test/java/jenkins/security/Security218CliTest.java core/src/main/java/hudson/cli/ListPluginsCommand.java core/src/main/java/hudson/cli/CLIAction.java core/src/main/java/hudson/cli/declarative/CLIRegisterer.java core/src/main/java/hudson/cli/ReloadJobCommand.java core/src/main/java/hudson/cli/HelpCommand.java test/src/test/java/hudson/cli/CLIRegistererTest.java test/src/test/java/hudson/cli/OnlineNodeCommandTest.java core/src/main/java/hudson/cli/OnlineNodeCommand.java core/src/main/java/hudson/cli/AddJobToViewCommand.java core/src/main/java/hudson/cli/CliProtocol2.java core/src/main/java/hudson/cli/CreateNodeCommand.java test/src/test/java/hudson/cli/DeleteJobCommandTest.java core/src/main/java/hudson/cli/CreateViewCommand.java test/src/test/java/hudson/cli/DeleteViewCommandTest.java core/src/main/java/hudson/cli/DeleteJobCommand.java core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java test/src/test/java/hudson/cli/ReloadJobCommandTest.java core/src/main/java/hudson/cli/CopyJobCommand.java

          Code changed in jenkins
          User: Jesse Glick
          Path:
          test/src/test/java/hudson/cli/GetNodeCommandTest.java
          test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
          http://jenkins-ci.org/commit/jenkins/9f3f352ee989c861e5304dc0ac4e7b06f7fd1403
          Log:
          JENKINS-32273 CLI exit codes changed as of #1997 in 1.649.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: test/src/test/java/hudson/cli/GetNodeCommandTest.java test/src/test/java/hudson/cli/UpdateNodeCommandTest.java http://jenkins-ci.org/commit/jenkins/9f3f352ee989c861e5304dc0ac4e7b06f7fd1403 Log: JENKINS-32273 CLI exit codes changed as of #1997 in 1.649.

            pajasoft Pavel Janoušek
            pajasoft Pavel Janoušek
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: