Closed
Description
Expected behavior
I have a top level skaffold file that requires all of my services, some of these services have before deploy hooks in them. I expect that running the top level skaffold file would sync the git repos and run each before deploy hook.
Actual behavior
Skaffold appears to be running the before deploy hook in the directory of the top level skaffold file, not in the directory of the git synced required skaffold file. I receive this error:
$ skaffold build --cache-artifacts=false
Generating tags...
- hello -> hello:a5c12d4
Starting build...
Found [kind-hmm] context, using local docker daemon.
Building [hello]...
Starting pre-build hooks...
fork/exec ./hello.sh: no such file or directory
This appears to be happening for at least build and deploy hooks.
Information
- Skaffold version:
v1.35.1
- Operating system:
Linux box 5.15.7-arch1-1 #1 SMP PREEMPT Wed, 08 Dec 2021 14:33:16 +0000 x86_64 GNU/Linux
- Installed via:
aur
- Contents of skaffold.yaml:
Parent
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: services
requires:
- git:
repo: https://github.com/jfyne/skaffold-child.git
path: skaffold.yaml
ref: main
sync: true
Child
apiVersion: skaffold/v2beta26
kind: Config
build:
local:
push: false
artifacts:
- image: hello
hooks:
before:
- command: [./hello.sh]
Steps to reproduce the behavior
git clone https://github.com/jfyne/skaffold-child.git
skaffold build --cache-artifacts=false
- Completes successfully, you should see
Hello $USER
in the pre build hooks output. git clone https://github.com/jfyne/skaffold-parent.git
skaffold build --cache-artifacts=false
- Fails with
fork/exec ./hello.sh: no such file or directory
DEBU[0000] skaffold API not starting as it's not requested subtask=-1 task=DevLoop
INFO[0000] Skaffold &{Version:v1.35.1 ConfigVersion:skaffold/v2beta26 GitVersion: GitCommit: BuildDate:2021-12-09T03:05:35Z GoVersion:go1.17.4 Compiler:gc Platform:linux/amd64 User:} subtask=-1 task=DevLoop
INFO[0000] Loaded Skaffold defaults from "/home/josh/.skaffold/config" subtask=-1 task=DevLoop
DEBU[0000] parsed 1 configs from configuration file /home/josh/p/src/github.com/jfyne/skaffold-parent/skaffold.yaml subtask=-1 task=DevLoop
DEBU[0000] Defaulting build type to local build subtask=-1 task=DevLoop
DEBU[0000] Running command: [/usr/bin/git remote -v] subtask=-1 task=DevLoop
DEBU[0000] Command output: [origin ssh://git@github.com/jfyne/skaffold-child.git (fetch)
origin ssh://git@github.com/jfyne/skaffold-child.git (push)
] subtask=-1 task=DevLoop
DEBU[0000] Running command: [/usr/bin/git fetch origin main] subtask=-1 task=DevLoop
DEBU[0001] Command output: [], stderr: From ssh://github.com/jfyne/skaffold-child
* branch main -> FETCH_HEAD subtask=-1 task=DevLoop
DEBU[0001] Running command: [/usr/bin/git diff --name-only --ignore-submodules HEAD] subtask=-1 task=DevLoop
DEBU[0001] Command output: [] subtask=-1 task=DevLoop
DEBU[0001] Running command: [/usr/bin/git diff --name-only --ignore-submodules origin/main...] subtask=-1 task=DevLoop
DEBU[0001] Command output: [] subtask=-1 task=DevLoop
DEBU[0001] Running command: [/usr/bin/git reset --hard origin/main] subtask=-1 task=DevLoop
DEBU[0001] Command output: [HEAD is now at a5c12d4 feat: MVP
] subtask=-1 task=DevLoop
DEBU[0001] parsed 1 configs from configuration file /home/josh/.skaffold/repos/CxU7wK9Ggh9iHhP7jYybNimV8POBVHTF/skaffold.yaml subtask=-1 task=DevLoop
INFO[0001] Using kubectl context: kind-hmm subtask=-1 task=DevLoop
DEBU[0001] Running command: [minikube version --output=json] subtask=-1 task=DevLoop
DEBU[0001] setting Docker user agent to skaffold-v1.35.1 subtask=-1 task=DevLoop
DEBU[0001] Using builder: local subtask=-1 task=DevLoop
INFO[0001] build concurrency first set to 1 parsed from *local.Builder[0] subtask=-1 task=DevLoop
DEBU[0001] Using builder: local subtask=-1 task=DevLoop
DEBU[0001] push value not present in NewBuilder, defaulting to false because cluster.PushImages is false subtask=-1 task=DevLoop
INFO[0001] build concurrency value 0 parsed from *local.Builder[1] is ignored since it's not less than previously set value 1 subtask=-1 task=DevLoop
INFO[0001] final build concurrency value is 1 subtask=-1 task=DevLoop
Generating tags...
- hello -> DEBU[0001] Running command: [git describe --tags --always] subtask=-1 task=Build
DEBU[0001] Command output: [a5c12d4
] subtask=-1 task=Build
DEBU[0001] Running command: [git status . --porcelain] subtask=-1 task=Build
DEBU[0001] Command output: [] subtask=-1 task=Build
hello:a5c12d4
INFO[0001] Tags generated in 1.539926ms subtask=-1 task=Build
Starting build...
Found [kind-hmm] context, using local docker daemon.
Building [hello]...
Starting pre-build hooks...
DEBU[0001] Running command: [./hello.sh] subtask=hello task=Build
DEBU[0001] Running command: [tput colors] subtask=-1 task=DevLoop
DEBU[0001] Command output: [256
] subtask=-1 task=DevLoop
fork/exec ./hello.sh: no such file or directory
DEBU[0001] exporting metrics subtask=-1 task=DevLoop