<p>I would like to run a command to clone a script from a remote repository before running <code>skaffold dev</code> I need to either somehow inject a <code>git clone</code> command or put the git clone command and the corresponding arguments in a shell script and run the shell script with Skaffold. </p>

<p>From the Skaffold workflow point of view, this step should be run before build. I am using Jib for the build phase and it appears that Jib state does not give me any ability to run a script before the actual build. I don't know if I can add a new phase to the Skaffold life cycle like <code>pre-build</code>. One solution came to my mind is to use <code>custom</code> build instead of <code>Jib</code> and put all pre-build commands as well as the jib related commands in a single script to run. This approach probably works, but won't be very convenient. I was wondering if there is a better approach to do this with Skaffold.</p>

<pre><code>build:
  artifacts:
    - image: gcr.io/k8s-skaffold/example
      custom:
        buildCommand: ./prebuild-and-build.sh
</code></pre>

<p>skaffold supports lifecycle hooks which allow running custom scripts before/after a build - <a href="https://skaffold.dev/docs/pipeline-stages/lifecycle-hooks/" rel="nofollow noreferrer">https://skaffold.dev/docs/pipeline-stages/lifecycle-hooks/</a></p>
<p>With this, you should be able to add a stanza in your skaffold.yaml similar to this:</p>
<pre><code>build:
  artifacts:
  - image: gcr.io/k8s-skaffold/example
    hooks:
      before:
        - command: [&quot;sh&quot;, &quot;-c&quot;, &quot;./prebuild-and-build.sh&quot;]
          os: [darwin, linux]
        # - command: # ...TODO
        #   os: [windows]
</code></pre>
<p>NOTE: This feature is relatively new, be sure to use the latest skaffold version (v1.33.0 at the time of this writing) for this feature</p>
