ServiceNow / servicenow-cicd-azure-extension

Extension for Azure Pipelines to help developers get started faster with ServiceNow's CI/CD APIs
MIT License
12 stars 18 forks source link

Issue with Instance Scan #42

Open vinay2099 opened 3 years ago

vinay2099 commented 3 years ago

Hello @chiarnglin

I am trying to work on Instance scan functionality via pipeline and i get the following error. "Exit code 1 returned from process: file name '/home/vsts/agents/2.187.2/externals/node/bin/node', arguments '"/home/vsts/work/_tasks/ServiceNow-CICD-Scan-Instance_daa79da8-c2e8-4a02-bbec-b94b8809432f/2.0.5/index.js"

Can you help me with this ?

chiarng commented 3 years ago

Hi @vinay2099, does this happen on every run? I haven't seen this before, I wonder if it's something wrong with the runner for Azure Pipelines. I tried Googling the error, but nothing really definitive showed up. I tried comparing different task files, not seeing anything really pop out. For example

I don't currently have more development budget for these right now, might need your team's assistance to figure this one out if it's recurring.

vinay2099 commented 3 years ago

Hello @chiarnglin

Below is my pipeline code i used and now i get error : "Scan failed

[error]Not found. The requested item was not found.

"

trigger:

stages:

chiarng commented 3 years ago

@vinay2099 Would you mind double checking inputs with the API documentation? https://developer.servicenow.com/dev.do#!/reference/api/quebec/rest/cicd-api#cicd-POST-instancescan-ss-sa

Also, try single quote marks around your scanType value And I'm assuming you're putting in the suiteSysID and appScopeSysIds values, just redacted for this comment?

For example if I try adding the build step, it comes up as follows

task: ServiceNow-CICD-Scan-Instance@2 inputs: connectedServiceName: 'chiarngtestdemo' scanType: 'suiteScoped' suiteSysId: '12415151' appScopeSysIds: '61646461'

vinay2099 commented 3 years ago

Hi @chiarnglin

I had a look at the documentation and tried using scanType: 'suiteScoped' but still i am getting the same error. I had provided the service connection, app sys id and appScopeSysIds as well. Also I assume the error will be given properly if its on servicenow side.(Correct me if i am wrong).

chiarng commented 3 years ago

Thanks, @vinay2099 Would you mind trying out the same input for the REST API Explorer on your instance, and let me know what the response is? The response you noted sounds like it's coming from the API, rather than the build step, but want to verify.

vinay2099 commented 3 years ago

Hi @chiarnglin

I did tried in REST API Explorer and it works fine. Returns the scan id and status as pending. Later when i try to check with id, i get the results using "Get Scan results"

For me the issue looks like its either on the extension code or the input 'appScopeSysIds'. (As it is an array and not string).

By seeing the logs in azure pipeline, I have a feeling that the error comes from line 46 in below code. https://github.com/ServiceNow/servicenow-cicd-azure-extension/blob/master/src/lib/ScanInstance.js

chiarng commented 3 years ago

@vinay2099

Sorry for the delayed response. I've been trying to find time to dig more into this but it's been tough on bandwidth. I don't currently have more budget for vendor engineering work on debugging and fixing this issue. In the spirit of open-source, is it possible for your team to take on submitting a PR to fix?

As you've tested, if the values are working in REST API Explorer, then there must be something wrong with how the extension is making requests for Instance Scan API specifically to get error responses. I'm a little concerned on if this is actually a problem of submitting as request body vs request header.

vinay2099 commented 3 years ago

Hello @chiarnglin

Sure.Thanks for your response. Just to inform you, I tried the full scan functionality and that also gives the same error. Full scan do not have any parameters needed still this did not triggered.

I will try to fix it and send PR(As i do not have complete knowledge on this). In the mean while if you get some budget, please have a look into it and let me know.

Kind regards, Vinay

mikevdberge commented 1 year ago

In the end the issue was fixed and we now using the ServiceNow-CICD-Scan-Instance@2 task without any issues. Regards Mike