-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Description
Attempting to trigger only specific intermediate build stages (step-two
in our example), but arg DEFINED_IN_SECOND_STEP
defined in intermediary step is not visible to our final stage, as witnessed by logged out "in final stage FINAL_ARG=[-extra-value]"
message.
Additionally, both step-one
& step-two
stages are executed, that should not happen.
drone.yml:
kind: pipeline
type: docker
name: default
steps:
- name: publish-image
image: plugins/docker
settings:
target: final
build_args:
- COMMON_STEP_VAR=common-step-value
- OPTIONAL_STEP=two # one | two
dry_run: true
debug: true
trigger:
ref:
- refs/heads/master
- refs/heads/develop
- refs/heads/feature/*
- refs/tags/*
Dockerfile:
ARG OPTIONAL_STEP
FROM alpine:3 AS base
ARG COMMON_STEP_VAR=common-step-default
RUN echo "start, COMMON_STEP_VAR=[$COMMON_STEP_VAR]"
FROM base AS step-one
ARG DEFINED_IN_SECOND_STEP=step-one-${COMMON_STEP_VAR}
RUN echo "in stage one, DEFINED_IN_SECOND_STEP=[$DEFINED_IN_SECOND_STEP]"
FROM base AS step-two
ARG DEFINED_IN_SECOND_STEP=step-two-${COMMON_STEP_VAR}
RUN echo "in stage two, DEFINED_IN_SECOND_STEP=[$DEFINED_IN_SECOND_STEP]"
FROM step-${OPTIONAL_STEP} AS final
ARG FINAL_ARG=${DEFINED_IN_SECOND_STEP}-extra-value
RUN echo "in final stage FINAL_ARG=[$FINAL_ARG]"
Running
$ docker build --rm=true -f Dockerfile -t deleteme . --pull=true \
--build-arg COMMON_STEP_VAR=common-step-value \
--build-arg OPTIONAL_STEP=two \
--target final
locally however logs out the expected
CACHED [final 1/1] RUN echo "in final stage FINAL_ARG=[step-two-common-step-value-extra-value]"
Also step-one
is not executed as expected.
Metadata
Metadata
Assignees
Labels
No labels