aws lambda
使用AWS CodeBuild,我正在使用一个buildspec,该规范运行一个可执行的JAR文件来执行JUnit测试。 这是我的buildspec:
version: 0.2 env: secrets-manager: CLIENT_ID: AppSecrets/someapp:CLIENT_ID CLIENT_SECRET: AppSecrets/someapp:CLIENT_SECRET phases: install: runtime-versions: java: corretto11 build: commands: - echo $CLIENT_ID - echo $CLIENT_SECRET - java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package= "com.wall.steve"
如您所见,我正在使用AWS Secrets Manager获得几个属性,这些属性作为系统变量传递给JUnit执行。
当此版本运行时,它将失败。 在日志中,我会看到以下错误:
[Container] 2020/10/16 14:18:55 Running command echo $CLIENT_ID *** [Container] 2020/10/16 14:18:55 Running command echo $CLIENT_SECRET *** [Container] 2020/10/16 14:18:55 Running command java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package= "com.wall.steve" Error: Unable to access jarfile from [Container] 2020/10/16 14:18:56 Command did not successfully java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package= exit successfully java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package= "com.wall.steve" exit status 1 [Container] 2020/10/16 14:18:56 Phase complete: BUILD State: FAILED
关于“无法访问jarfile”错误的堆栈溢出问题的答案主要是谈论对JAR文件本身的访问/权限。 这不是我的问题。
就我而言,是由于我在AWS Secrets Manager中为客户端ID和客户端密钥设置的值不正确而引起的。 设置正确的值后,我的构建就通过了!
翻译自: https://www.javacodegeeks.com/2020/10/aws-codebuild-error-unable-to-access-jarfile.html
aws lambda