@@ -56,34 +56,43 @@ public class CheckmarxInstaller extends ToolInstaller {
5656 public static final String cliDefaultVersion = "2.3.18" ;
5757 private static final String cliVersionFileName = "cli.version" ;
5858 @ Getter
59- private final String version ;
59+ private String version ;
6060 @ Getter
6161 private final Long updatePolicyIntervalHours ;
6262 private CxLoggerAdapter log ;
6363
6464 @ DataBoundConstructor
6565 public CheckmarxInstaller (String label , String version , Long updatePolicyIntervalHours ) {
6666 super (label );
67- this .version = "latest" . equalsIgnoreCase ( version . trim ()) || version . isEmpty () ? readCLILatestVersionFromVersionFile () : version ;
67+ this .version = version ;
6868 this .updatePolicyIntervalHours = updatePolicyIntervalHours ;
6969 }
7070
7171 @ Override
7272 public FilePath performInstallation (ToolInstallation toolInstallation , Node node , TaskListener taskListener ) throws IOException , InterruptedException {
7373 log = new CxLoggerAdapter (taskListener .getLogger ());
74-
74+ String versionToInstall = getVersionNumber ();
7575 FilePath expected = preferredLocation (toolInstallation , node );
7676
7777 if (isUpToDate (expected , log )) {
7878 log .info ("Checkmarx installation is UP-TO-DATE" );
7979 return expected ;
8080 }
81- log .info ("Installing Checkmarx AST CLI tool (version '" + fixEmptyAndTrim (version ) + "')" );
8281
83- return installCheckmarxCliAsSingleBinary (expected , node , taskListener );
82+ log .info ("Installing Checkmarx AST CLI tool (version '{}')" , fixEmptyAndTrim (versionToInstall ));
83+
84+ return installCheckmarxCliAsSingleBinary (versionToInstall , expected , node , taskListener );
85+ }
86+
87+ public String getVersionNumber () {
88+ if ("latest" .equalsIgnoreCase (version .trim ()) || version .isEmpty ()) {
89+ return readCLILatestVersionFromVersionFile ();
90+ } else {
91+ return version ;
92+ }
8493 }
8594
86- private String readCLILatestVersionFromVersionFile () {
95+ public String readCLILatestVersionFromVersionFile () {
8796 try {
8897 Path versionFilePath = findVersionFilePath ().orElseThrow (() -> new ToolDetectionException ("Could not find version file" ));
8998 String fileVersion = Files .readString (versionFilePath .resolve (cliVersionFileName )).trim ();
@@ -130,7 +139,7 @@ private boolean isUpToDate(FilePath expectedLocation, CxLoggerAdapter log) throw
130139 return timestampDifference < updateInterval ;
131140 }
132141
133- private FilePath installCheckmarxCliAsSingleBinary (FilePath expected , Node node , TaskListener log ) throws IOException , InterruptedException {
142+ private FilePath installCheckmarxCliAsSingleBinary (String version , FilePath expected , Node node , TaskListener log ) throws IOException , InterruptedException {
134143 final VirtualChannel nodeChannel = node .getChannel ();
135144 if (nodeChannel == null ) {
136145 throw new IOException (format ("Node '%s' is offline" , node .getDisplayName ()));
0 commit comments