dependency-check / azuredevops

Dependency Check Azure DevOps Extension
Apache License 2.0
47 stars 25 forks source link

Java not found - exit code 9009 #46

Closed paulmrozowski closed 4 years ago

paulmrozowski commented 4 years ago

I'm trying to add this as a step in one of our Azure DevOps deployments. However, it keeps failing with " 'java' is not recognized as an internal or external command":

2020-09-22T12:48:21.2708345Z ==============================================================================
2020-09-22T12:48:21.2709349Z Task         : OWASP Dependency Check
2020-09-22T12:48:21.2711297Z Description  : Dependency Check is a Software Composition Analysis (SCA) tool that attempts to detect publicly disclosed vulnerabilities contained within a project's dependencies.
2020-09-22T12:48:21.2712627Z Version      : 5.3.2003
2020-09-22T12:48:21.2713304Z Author       : Dependency Check
2020-09-22T12:48:21.2714342Z Help         : [More Information](https://jeremylong.github.io/DependencyCheck/index.html)
2020-09-22T12:48:21.2715497Z ==============================================================================
2020-09-22T12:48:23.4445503Z Starting Dependency Check...
2020-09-22T12:48:23.6401335Z Downloading Dependency Check installer...
2020-09-22T12:48:33.2340098Z Invoking Dependency Check...
2020-09-22T12:48:33.2400801Z Path: C:\azagent\A1\_work\_tasks\dependency-check-build-task_47ea1f4a-57ba-414a-b12e-c44f42765e72\5.3.2003\dependency-check\bin\dependency-check.bat
2020-09-22T12:48:33.2418414Z Arguments: --project "Web" --scan "C:\azagent\A1\_work\r1\a\**\*.csproj" --out "\dependency-check" --exclude "C:\azagent\A1\_work\r1\a" --format HTML --failOnCVSS 8 --suppression "C:\azagent\A1\_work\r1\a"
2020-09-22T12:48:33.3286473Z 'java' is not recognized as an internal or external command,
2020-09-22T12:48:33.3287988Z operable program or batch file.
2020-09-22T12:48:34.2890567Z Dependency Check completed with exit code 9009.
2020-09-22T12:48:34.2907107Z Dependency check reports:
2020-09-22T12:48:34.4252429Z ##[error]Dependency Check exited with an error code.
2020-09-22T12:48:34.4493346Z Ending Dependency Check...
2020-09-22T12:48:34.4957837Z ##[section]Finishing: Dependency Check

I found this issue which is the same scenario (we're running this on our own build server running Windows Server 2019). I downloaded the Java runtime (I've tried this with both the 64-bit version and, when that didn't work, I uninstalled it and installed the 32-bit version). In both cases I went into System Properties > Advanced > Environment Variables and configured the System variables.

I created these two settings:

JAVA_HOME   C:\PROGRA~2\Java\jre1.8.0_261
JAVACMD     C:\PROGRA~2\Java\jre1.8.0_261\bin

I also tried adding the jre1.8.0_261\bin folder to the path.

But when I redeploy it still fails with the same error. I'm not quite sure what else to try.

ejohn20 commented 4 years ago

I suspect this is likely due to the service account running the process can't locate Java. I would suggest running a PowerShell task directly on the build agent to confirm Java is being properly located by the build task.

ejohn20 commented 4 years ago

Closing due to inactivity.