AnsweredAssumed Answered

How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config

Question asked by ahmmo05 Employee on Nov 21, 2017
Latest reply on Nov 22, 2017 by tsuyu04

Hi ,

 

 

I have a groovy script, refer below for groovy script content:

 

 

import com.***;

  

// Enter core server IP address

String coreServerIpAddress = System.getProperty("core.server.url");

  

private ReferenceDataServiceCover refSrv = null;

 


refSrv = new ReferenceDataServiceCover(coreServerIpAddress);

  

long versionId = Long.valueOf(args[1]);

String source = args[2];

String url = args[3];

String description = args[4];

double score = Double.valueOf(args[5]);

String severity = args[6];

  

println("versionId: " + versionId);

println("source: " + source);

println("url: " + url);

println("description: " + description);

println("score: " + score);

println("severity: " + severity);

  

  

if (refSrv == null) {

throw new Exception("Unable to initialize app instance at: ${Url}");

}

  

if (refSrv != null) {

 


try {

long vulnId=refSrv.createVulnerability(versionId, source, url, description,

score, severity)

println("Sucessfully created/updated vulnerability."+vulnId);

} catch (Exception e) {

e.printStackTrace();

println("Unable to create vulnerability.");

}

 


}

========================


Create a .sh file with following content


#!/bin/bash

PAL_JAVA_HOME=/opt/java/jdk1.8.0_151

  

#!/bin/bash

export PAL_JAVA_HOME

  

#!/bin/bash

cd /root/VulScriptRunner/scriptRunner/scripts

  

#!/bin/bash

../bin/scriptRunner.sh -c http://server/ -u ahmmo05 securitynotifications/createVulnerability.groovy DEV $1 $2 $3 $4 $5 $

 


Create 6 variables that accept the above 6 arguments in project.confih


create SSH step > add host details > In SSH command enter following:

 

 

./createNewVulnerabilities.sh {{VersionID}} {{VulName}} {{URL}} {{Description}} {{Score}} {{Severity}}

 


This throws number format exception

 

 

It works if we pass SSH command as :

./createNewVulnerabilities..sh "3058290" "test_javaxvul1" "javaxurl" "javaxdesc" "0.0" "high"


Please do suggest a solution

 

 

Regards


Irfan

Outcomes