<p>Few ideas to help you</p>

<ol>
<li><p>When you define a "CodeBuild" project, you can specify which base image it will use to execute your commands. The one you are using is not Ubuntu yet you are trying <code>apt-get</code>. Try a different base image.</p></li>
<li><p>Provide us with a better log stream.</p></li>
</ol>

<h3>Exporting Logs from CloudWatch</h3>

<p>I found that the easiest way is to export logs through command-line:</p>

<ul>
<li>click on 'View Logs' link, to find out your Log Group and Log Stream</li>
<li>install "awscli" and "jq"</li>
</ul>

<p>Run substituting your log-group-name and -log-stream-name:</p>

<pre><code>aws logs get-log-events --log-group-name /aws/codebuild/Dumper  \
    --log-stream-name 0bd74b8c-74b9-4f9b-b275-167b45901aa3 | \
    jq '.events[].message' -r | grep -v '^$'
</code></pre>

<p>This should give you the output, which you can include in the question.</p>

CC BY-SA 3.0
2017-07-13T21:57:28.583Z
2017-08-16T15:56:48.043Z
2017-08-16T15:56:48.043Z
romaninsh
<p>I have <strong><em>Java Spring web service project on EC2</em></strong> </p>

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

<p><a href="https://i.sstatic.net/FoLky.jpg" rel="noreferrer"><img src="https://i.sstatic.net/FoLky.jpg" alt="This is my buildspec file."></a></p>

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

<p><a href="https://i.sstatic.net/O4jY0.jpg" rel="noreferrer"><img src="https://i.sstatic.net/O4jY0.jpg" alt="These are the logs of the build"></a></p>

CC BY-SA 3.0
2017-06-12T11:53:01.903Z
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)
Tensibai
CC BY-SA 3.0
2017-07-03T13:54:56.217Z
Did you already try putting a "-y" for your apt-get commands?
Subin Mathew
CC BY-SA 3.0
2017-07-03T14:47:21.773Z
@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.
Tensibai
<amazon-web-services><spring-boot>
How do I write a buildspec.yml file?
retr0
# How do I write a buildspec.yml file?

(Asked by: username_0 on 2017-06-12)

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.](https://i.sstatic.net/FoLky.jpg)](https://i.sstatic.net/FoLky.jpg)

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](https://i.sstatic.net/O4jY0.jpg)](https://i.sstatic.net/O4jY0.jpg)

**Tags:** amazon-web-services, spring-boot

> **Comments:**
> **username_1**: 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)  
> **username_2**: Did you already try putting a "-y" for your apt-get commands?  
> **username_1**: @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.  

---

## 1 answers

### Answer by username_3 on 2017-07-13. Score: 7

Few ideas to help you

When you define a "CodeBuild" project, you can specify which base image it will use to execute your commands. The one you are using is not Ubuntu yet you are trying apt-get. Try a different base image.
Provide us with a better log stream.

Exporting Logs from CloudWatch
I found that the easiest way is to export logs through command-line:

click on 'View Logs' link, to find out your Log Group and Log Stream
install "awscli" and "jq"

Run substituting your log-group-name and -log-stream-name:
aws logs get-log-events --log-group-name /aws/codebuild/Dumper  \
    --log-stream-name 0bd74b8c-74b9-4f9b-b275-167b45901aa3 | \
    jq '.events[].message' -r | grep -v '^$'

This should give you the output, which you can include in the question.


---

