title: Upload jest code coverage results to codecov during google cloud build
body: <p>I'm trying to figure out how to upload my jest code coverage reports to codecov. 
  From there <a href="https://docs.codecov.io/docs/about-the-codecov-bash-uploader#section-flag" rel="nofollow noreferrer">documentation</a>:</p>
  
  <pre><code>bash &lt;(curl -s https://codecov.io/bash) -t token
  </code></pre>
  
  <p>So I tried to run the bash script from a cloud build step witth the following <code>cloudbuild.yaml</code></p>
  
  <pre><code>steps:
    - name: node:10.15.1
      entrypoint: npm
      args: ["install"]
    - name: node:10.15.1
      entrypoint: npm
      args: ["test", "--", "--coverage"]
    - name: 'gcr.io/cloud-builders/curl'
      entrypoint: bash
      args: ['&lt;(curl -s https://codecov.io/bash)', '-t', '$_CODECOV_TOKEN']
    - name: node:10.15.1
      entrypoint: npm
      args: ["run", "build:production"]
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>Step #2: bash: &lt;(curl -s https://codecov.io/bash): No such file or directory
  </code></pre>
  
  <p>Obviously because the <code>&lt;(curl -s https://codecov.io/bash)</code> is interpreted as string while I want it to be executed.</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>I've changed my build step to the following: </p>
  
  <pre><code>  - name: "gcr.io/cloud-builders/curl"
      entrypoint: bash
      args: ["./scripts/codecov-upload.bash", "$_CODECOV_TOKEN"]
  </code></pre>
  
  <p>And added a file <code>codecov-upload.bash</code></p>
  
  <pre><code>bash &lt;(curl -s https://codecov.io/bash) -t $1
  </code></pre>
  
  <p>When running my cloud build the codecov bash uploader succesfully starts. However, I doesn't manage to upload to reports to clodecov.</p>
  
  <p>Here's the logs from codecov bash uploader:</p>
  
  <pre><code>Step #2: Test Suites: 1 passed, 1 total
  Step #2: Tests:       1 passed, 1 total
  Step #2: Snapshots:   1 passed, 1 total
  Step #2: Time:        28.981s
  Step #2: Ran all test suites.
  Finished Step #2
  Starting Step #3
  Step #3: Already have image (with digest): gcr.io/cloud-builders/curl
  Step #3: /dev/fd/63: option requires an argument -- t
  Step #3: 
  Step #3:   _____          _
  Step #3:  / ____|        | |
  Step #3: | |     ___   __| | ___  ___ _____   __
  Step #3: | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
  Step #3: | |___| (_) | (_| |  __/ (_| (_) \ V /
  Step #3:  \_____\___/ \__,_|\___|\___\___/ \_/
  Step #3:                               Bash-tbd
  Step #3: 
  Step #3: 
  Step #3: x&gt; No CI provider detected.
  Step #3:     Testing inside Docker? http://docs.codecov.io/docs/testing-with-docker
  Step #3:     Testing with Tox? https://docs.codecov.io/docs/python#section-testing-with-tox
  Step #3:     project root: .
  Step #3: /dev/fd/63: line 897: git: command not found
  Step #3: /dev/fd/63: line 897: hg: command not found
  Step #3:     Yaml not found, that's ok! Learn more at http://docs.codecov.io/docs/codecov-yaml
  Step #3: ==&gt; Running gcov in . (disable via -X gcov)
  Step #3: ==&gt; Python coveragepy not found
  Step #3: ==&gt; Searching for coverage reports in:
  Step #3:     + .
  Step #3:     -&gt; Found 3 reports
  Step #3: ==&gt; Detecting git/mercurial file structure
  Step #3: ==&gt; Reading reports
  Step #3:     + ./coverage/clover.xml bytes=163786
  Step #3:     + ./coverage/coverage-final.json bytes=444241
  Step #3:     + ./coverage/lcov.info bytes=71582
  Step #3: ==&gt; Appending adjustments
  Step #3:     http://docs.codecov.io/docs/fixing-reports
  Step #3:     + Found adjustments
  Step #3: ==&gt; Gzipping contents
  Step #3: ==&gt; Uploading reports
  Step #3:     url: https://codecov.io
  Step #3:     query: branch=&amp;commit=&amp;build=&amp;build_url=&amp;name=&amp;tag=&amp;slug=&amp;service=&amp;flags=&amp;pr=&amp;job=
  Step #3:     -&gt; Pinging Codecov
  Step #3: https://codecov.io/upload/v4?package=bash-tbd&amp;token=secret&amp;branch=&amp;commit=&amp;build=&amp;build_url=&amp;name=&amp;tag=&amp;slug=&amp;service=&amp;flags=&amp;pr=&amp;job=
  Step #3:     -&gt; Uploading
  Step #3:     X&gt; Failed to upload
  Step #3:     -&gt; Sleeping for 30s and trying again...
  Step #3:     -&gt; Pinging Codecov
  Step #3: https://codecov.io/upload/v4?package=bash-tbd&amp;token=secret&amp;branch=&amp;commit=&amp;build=&amp;build_url=&amp;name=&amp;tag=&amp;slug=&amp;service=&amp;flags=&amp;pr=&amp;job=
  Step #3:     -&gt; Uploading
  Step #3:     X&gt; Failed to upload
  Step #3:     -&gt; Sleeping for 30s and trying again...
  Step #3:     -&gt; Pinging Codecov
  Step #3: https://codecov.io/upload/v4?package=bash-tbd&amp;token=secret&amp;branch=&amp;commit=&amp;build=&amp;build_url=&amp;name=&amp;tag=&amp;slug=&amp;service=&amp;flags=&amp;pr=&amp;job=
  Step #3:     -&gt; Uploading
  Step #3:     X&gt; Failed to upload
  Step #3:     -&gt; Sleeping for 30s and trying again...
  Step #3:     -&gt; Pinging Codecov
  Step #3: https://codecov.io/upload/v4?package=bash-tbd&amp;token=secret&amp;branch=&amp;commit=&amp;build=&amp;build_url=&amp;name=&amp;tag=&amp;slug=&amp;service=&amp;flags=&amp;pr=&amp;job=
  Step #3:     -&gt; Uploading
  Step #3:     X&gt; Failed to upload
  Step #3:     -&gt; Sleeping for 30s and trying again...
  Step #3:     -&gt; Uploading to Codecov
  Step #3:     HTTP 400
  Step #3: missing required properties: [&amp;#39;commit&amp;#39;]
  Finished Step #3
  Starting Step #4
  Step #4: Already have image: node:10.15.1
  Step #4: 
  </code></pre>
  
  <p>I've noticed two things in the logs:</p>
  
  <pre><code>1. Step #3: /dev/fd/63: option requires an argument -- t
  2. Step #3: missing required properties: [&amp;#39;commit&amp;#39;]
  </code></pre>
  
  <p>When searching to fix number 2, I found the following on SO: 
  <a href="https://stackoverflow.com/questions/44749241/codecov-io-gives-error-in-combination-with-bitbucket-pipelines">codecov.io gives error in combination with Bitbucket pipelines</a></p>
  
  <p>Where the answer seems to be to that git is not installed in my container.</p>
  
  <p>So I've tried to make a custom container image with docker:</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM gcr.io/cloud-builders/curl
  RUN apt-get update &amp;&amp; \
      apt-get upgrade -y &amp;&amp; \
      apt-get install -y git
  </code></pre>
  
  <p>So I build the image: </p>
  
  <pre><code>build -t "gcr.io/[PROJECT_ID]/builder .
  </code></pre>
  
  <p>And update my build step to use this image instead: </p>
  
  <ul>
  <li>name: "gcr.io/$PROJECT_ID/builder"
  entrypoint: bash
  args: ["./scripts/codecov-upload.bash"]</li>
  </ul>
  
  <p>But using the image created with that dockerfile returns the same errors.</p>
  
  <p>Maybe the Dockerfile for that custom image isn't correct? Or I'm missing something else? </p>
  
  <p>My code is available on github: <a href="https://github.com/thdk/timesheets/tree/feat/112-1" rel="nofollow noreferrer">https://github.com/thdk/timesheets/tree/feat/112-1</a></p>