<p>I am using Google's Cloud Code extension with Visual Studio Code to use GCP's Cloud Build and deploy to a local kubernetes cluster (Docker Desktop). I have directed Cloud Build to run unit tests after installing modules.</p>
<p>When I build using the command line <code>gcloud beta builds submit</code>, the Cloud Build does the module install and successfully fails to build because I intentionally wrote a failing unit test. So that's great.</p>
<p>However, when I try to build and deploy using the Cloud Code extension, it is not using my cloudbuild.yaml at all. I know this because the</p>
<p>1.) The build succeeds even with the failing unit test</p>
<p>2.) No logging from the unit test appears in GCP logging</p>
<p>3.) I completely deleted cloudbuild.yaml and the build / deploy still succeeded, which seems to imply Cloud Code is using Dockerfile</p>
<p>What do I need to do to ensure Cloud Code uses cloudbuild.yaml for its build/deploy to a local instance of kubernetes?</p>
<p>Thanks!</p>
<p><strong>cloudbuild.yaml</strong></p>
<pre class="lang-yaml prettyprint-override"><code>steps:
- name: node
  entrypoint: npm
  args: ['install']
- id: &quot;test&quot;
  name: node
  entrypoint: npm
  args: ['test']
options:
  logging: CLOUD_LOGGING_ONLY
</code></pre>
<p><strong>scaffold.yaml</strong></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: skaffold/v2beta19
kind: Config
build:
  tagPolicy:
    sha256: {}
  artifacts:
  - context: .
    image: genesys-gencloud-dev
deploy:
  kubectl:
    manifests:
    - kubernetes-manifests/**
profiles:
- name: cloudbuild
  build:
    googleCloudBuild: {}
</code></pre>
<p><strong>launch.json</strong></p>
<pre class="lang-json prettyprint-override"><code>{
  &quot;configurations&quot;: [
    {
      &quot;name&quot;: &quot;Kubernetes: Run/Debug - cloudbuild&quot;,
      &quot;type&quot;: &quot;cloudcode.kubernetes&quot;,
      &quot;request&quot;: &quot;launch&quot;,
      &quot;skaffoldConfig&quot;: &quot;${workspaceFolder}\\skaffold.yaml&quot;,
      &quot;profile&quot;: &quot;cloudbuild&quot;,
      &quot;watch&quot;: true,
      &quot;cleanUp&quot;: false,
      &quot;portForward&quot;: true,
      &quot;internalConsoleOptions&quot;: &quot;neverOpen&quot;,
      &quot;imageRegistry&quot;: &quot;gcr.io/my-gcp-project&quot;,
      &quot;debug&quot;: [
        {
          &quot;image&quot;: &quot;my-image-dev&quot;,
          &quot;containerName&quot;: &quot;my-container-dev&quot;,
          &quot;sourceFileMap&quot;: {
            &quot;${workspaceFolder}&quot;: &quot;/WORK_DIR&quot;
          }
        }
      ]
    }
  ]
}
</code></pre>

Dshiz
<p>You will need to edit your <code>skaffold.yaml</code> file to use Cloud Build:</p>
<pre><code>build:
  googleCloudBuild: {}
</code></pre>
<p>See <a href="https://skaffold.dev/docs/pipeline-stages/builders/#remotely-on-google-cloud-build" rel="nofollow noreferrer">https://skaffold.dev/docs/pipeline-stages/builders/#remotely-on-google-cloud-build</a> for more details.</p>
<p><strong>EDIT</strong>: It looks like your skaffold.yaml enables cloud build for the <code>cloudbuild</code> profile, but that the profile isn't active.</p>
<p>Some options:</p>
<ul>
<li>Add <code>&quot;profile&quot;: &quot;cloudbuild&quot;</code> to your <code>launch.json</code> for 'Run on Kubernetes'.
<a href="https://i.stack.imgur.com/atgOw.png" rel="nofollow noreferrer">Screenshot</a></li>
<li>Move the <code>googleCloudBuild: {}</code> to the top-level <code>build:</code> section. (In other words, skip using the profile)</li>
<li>Activate the profile using one of the other methods from <a href="https://skaffold.dev/docs/environment/profiles/#activation" rel="nofollow noreferrer">https://skaffold.dev/docs/environment/profiles/#activation</a></li>
</ul>
<p><strong>UDPATE</strong> (from asker)</p>
<p>I needed to do the following:</p>
<ol>
<li>Update <code>skaffold.yaml</code> as follows. In particular note the <code>image</code>, field under build &gt; artifacts, and <code>projectId</code> field under profiles &gt; build.</li>
</ol>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: skaffold/v2beta19
kind: Config
build:
  tagPolicy:
    sha256: {}
  artifacts:
  - context: .
    image: gcr.io/my-project-id/my-image
deploy:
  kubectl:
    manifests:
    - kubernetes-manifests/**
profiles:
- name: cloudbuild
  build:
    googleCloudBuild:
      projectId: my-project-id
</code></pre>
<ol start="2">
<li>Run this command to activate the profile: <code>skaffold dev -p cloudbuild</code></li>
</ol>
