I'm building a simple hello world application in java (based on spring) which I launch to AWS through a pipeline.
The buildspec.yml is defined as follows:
version: 0.2
phases:
install:
runtime-versions:
java: openjdk8
build:
commands:
- mvn package
artifacts:
files:
- '**/*'
with the appspec.yml as follows:
version: 0.0
os: linux
files:
- source: target/helloworld-1.0-SNAPSHOT.jar
destination: /tmp
hooks:
ApplicationStart:
- location: codedeploy/ApplicationStart.sh
timeout: 60
runas: root
The file codedeploy/ApplicationStart.sh:
#!/usr/bin/env bash
JAR_FILE_HOME='/tmp/helloworld-1.0-SNAPSHOT.jar'
java -jar JAR_FILE_HOME
Weirdly enough the deployment fails with the following error:
Script at specified location: codedeploy/ApplicationStart.sh run as user root failed with exit code 127
Output log:
[stderr]/opt/codedeploy-agent/deployment-root/5092b759-ecc4-44cb-859a-9823734abc04/d-GVQ6R854B/deployment-archive/codedeploy/ApplicationStart.sh: line 9: java: command not found
This seems very counter-intuitive since I've installed java in the buildspec.yml. Do I need to install java manually again within the ApplicationStart script or am I doing something else wrong?