<p>I need to build go project using google Ko after checking out from git and then push the image to private artifactory which takes credentials. How to define the steps for the above in cloudbuild.yaml? Steps where it takes Source path and also where it takes private repository path. How to give the credentials of artifactory through script?</p>

<p>Error you are getting is due the <code>failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: &quot;bash&quot;</code></p>
<blockquote>
<p>By default, the ko command uses a secure and lean base image from the
Distroless collection of images (the gcr.io/distroless/static:nonroot
image), which doesn’t contain a shell or other executables in order to
reduce the attack surface of the container.</p>
</blockquote>
<p>You can first create the <strong>Ko</strong> docker image and we will use this docker image as the base iamge to Cloudbuild. We will push and save the <strong>Ko</strong> docker image to <strong>GCR</strong></p>
<p>Github : <a href="https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/ko" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/ko</a></p>
<p>There is <code>cloudbuild.yaml</code> to build image on <strong>cloudbuild</strong> or you also run <code>docker build -t</code> locally to build docker</p>
<p>Once docker image is built and pushed to the <strong>GCR</strong> we can write the <code>cloudbuild.yaml</code> to build the application</p>
<p>Try this <code>Cloudbuild.yaml</code> for example</p>
<pre><code>steps:
  - name: gcr.io/$PROJECT_ID/ko
    entrypoint: /bin/sh
    env:
      - 'KO_DOCKER_REPO=gcr.io/$PROJECT_ID'
    args:
      - -c
      - |
        echo $(/ko publish --preserve-import-paths ./cmd/ko) &gt; ./ko_container.txt || exit 1
</code></pre>
