GoogleContainerTools / GoogleContainerTools/skaffold

Support for Pre-tag hook

Open
#7,311 4 comments 0 reactions 0 assignees View on GitHub
area/hooks kind/feature-request priority/p2
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

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 :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.