jenkinsci / ibm-security-appscansource-scanner-plugin

Jenkins plugin for executing AppScan Source
https://plugins.jenkins.io/ibm-security-appscansource-scanner/
GNU General Public License v3.0
5 stars 7 forks source link

Plugin fails as a pipeline job #8

Open kevinfealey opened 6 years ago

kevinfealey commented 6 years ago

From a user:

Here is the screenshots and errors…

It doesn’t matter if I set master node, or use this fake local_slave configuration, I get the same error:

stage( 'Run AppScan Source') {
   node ( 'local_slave' ) {
        step([$class: 'AppScanSourceBuilder', acceptSSL: false, applicationFile: 'C:\\Users\\Madfast\\Downloads\\<snip>.paf', customScanWorkspace: 'C:\\Users\\Madfast\\Downloads\\<snip>\\ analysis', disableScan: false, installation: 'AppScanSource Local'])
   }
}
Started by user admin
[Pipeline] stage
[Pipeline] { (Run AppScan Source)
[Pipeline] node
Running on local_slave in d:\jenkins\workspace\Jenkins Pipeline Example - AppScan Source
[Pipeline] {
[Pipeline] step
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: The AppScan Source build step requires to be launched on a node
Finished: FAILURE

I believe the error here is with https://github.com/kevinfealey/appscansource-scanner/blob/ec0f0f7a5045d18761ff725abcb5308abe5f7c69/src/main/java/com/aspectsecurity/automationservices/plugins/jenkins/appscansource/AppScanSourceBuilder.java

Specifically with line 95: Computer computer = Computer.currentComputer(); and line 99: computer.getNode() I think it is expected in a pipeline for currentComputer() to return null, and it always seems to. Instead, I think this value needs to be set via the @StepContextParameter annotation (see: https://jenkins.io/blog/2016/05/25/update-plugin-for-pipeline/).

The fix therefore should be to remove line 95 (or possibly only execute it when node is null), and add:

@StepContextParameter
private transient Computer computer

as a class variable. A team member tried this, but did not see the plugin in Jenkins post-install. We did not have time to debug.