How do I write a buildspec.yml file?

HOW TO -️ October 18, 2021

I have Java Spring web service project on EC2

I tried writing a buildspec.yml for it. However the AWS CodeBuild service is not giving successful results. In the install phase itself, it tells apt-get and yum command not found. The problem is that both yum and apt-get are not being detected. However the exemplary file in the docs is using apt-get to in the install phase. How can I make it work?

This is my buildspec file.

I am not able to figure it out... why does it fail for both yum and apt-get?

These are the logs of the build

Answer

Both of your screenshot shows only apt-get in error... which makes sense if it's running on a RH based distribution. It's unclear what makes you think somethign with yum fail. For the future, please avoid screenshots of file content, it's harder to read and impossible to test and validate (no copy/paste possible) Did you already try putting a "-y" for your apt-get commands? @subinmathew Here it's apt-get update which is failing, it doesn't have a -y switch (it's ignored if present) as it never ask anything to the user.

Initializing...