DerScanner Integration via The Command Line Runner
To integrate into the TeamCity process via Command Line Runner:
-
Add Build Step with Command Line runner type in Build Configuration Settings.
-
Develop a script to run the scan in DerScanner:
- the project and environment settings are accessible via
%key%
(Predefined Build Parameters); - scan start script example:
java -jar <path>/clt.jar -rest http://<installation_address>/app/api/v1 -token xxx -name TeamCityCLTTest -languages JAVA -type FILE -path %teamcity.build.checkoutDir
- the project and environment settings are accessible via
When creating a Build Step with Command Line runner type, use Custom script as Run, rather than Executable with parameters.
The following example uses PowerShell Build Step. This script starts the scan, gets its ID, and waits for its completion. After the scan is complete, you can download the PDF report via CLI.
$out = java -jar <path>\clt.jar -rest http://<installation_address>/app/api/v1 -token xxx -name TeamCityTest -languages JAVA -type FILE -path %teamcity.build.checkoutDir%;
$sep = "ScanUuid: ";
$line = $out.Where{$_.Contains($sep)}.Item(0);
$splitted = $line -split $sep;
$id = $splitted[1];
For ($i=0; $i -lt 12; $i++) {
$out = java -jar <path>\clt.jar -rest http://<installation_address>/app/api/v1 -token xxx -cmd status -scanid $id;
$sep = "Status: ";
$line = $out.Where{$_.Contains($sep)}.Item(0);
$splitted = $line -split $sep;
$status = $splitted[1];
write-host $( '##teamcity[message text=''{0}'']' -f $status );
if ($status -eq "Scan completed"){
break;
}
Start-Sleep -s 5;
}
java -jar <path>\clt.jar -rest http://<installation_address>/app/api/v1 -token xxx -cmd export -scanid $id –path <path> -default;