image
value from yaml gets expanded to fully qualified name, breaking local backend
#1003
Closed
4 tasks done
Component
server
Describe the bug
When parsing the
image
in a pipeline yaml, the given value is always expanded to a fully qualified docker image name very early:woodpecker/pipeline/frontend/yaml/compiler/convert.go
Line 23 in 3f73d5b
For example, if you have
image: alpine
, you will getdocker.io/library/alpine:latest
.First, it is questionable whether this kind of expansion should be done on the server at all, as the docker or podman on the agent machine could figure this out themselves, as @6543 noted on matrix.
But second, this is a major problem for the local backend where the image value is not interpreted as a docker image, but as the name of the shell to run commands in.
Currently there is this hack in place, which tries to chop off the prefix and suffix again:
woodpecker/pipeline/backend/local/local.go
Line 65 in 3f73d5b
So you pass
image: bash
andproc.Image[18:len(proc.Image)-7]
will evaluate tobash
. But this of course is only a very fragile workaround. For example it panics and crashes the agent as soon as you pass something likeimage: /bin/bash
, which will not get anything added by the expansion.This by itself could also be fixed by not reusing the
image
key for the shell and instead adding an additional one.System Info
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: