Skip to content

Support for Pre-tag hook #7311

Open
Open
@JJRdec

Description

This probably a feature request - unless there is support already available

I am trying to use pre-build hooks to run a command which parses and stores my app's version as an environment variable ($APP_VERSION) from a properties file. Then I use envTemplate to reference variable for the tagPolicy.

As you can see in the output snippet the image is tagged before the pre-build hook runs. I would like to parse and export the version with hooks before the tags are generated.

Also, my command works great on the command line however not when used with hooks - any tips?

Skaffold Snippet:

apiVersion: skaffold/v2beta28
kind: Config
profiles:
  - name: local
    build:
      tagPolicy:
        envTemplate:
          template: "{{.APP_VERSION}}"
      artifacts:
        - image: my-app
          hooks:
            before:
              - command: [ "sh", "-c", "export APP_VERSION=$(grep \"applicationVersion\" gradle.properties | awk -F '='  '{ print $2 }')" ]
                os: [ darwin, linux ]
          custom:
            buildCommand: ./build.sh

Output Snippet:
Command: skaffold dev -p local

Listing files to watch...
 - my-app
Generating tags...
 - my-app -> my-app:latest
Some taggers failed. Rerun with -vdebug for errors.
Starting build...
Found [docker-desktop] context, using local docker daemon.
Building [my-app]...
Target platforms: [linux/amd64]
Starting pre-build hooks...
Completed pre-build hooks
.
.

Any thoughts?

Many thanks in advance :)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions