diff --git a/builder/build/dockerfile_build.go b/builder/build/dockerfile_build.go index a187a76d63..d0b9579058 100644 --- a/builder/build/dockerfile_build.go +++ b/builder/build/dockerfile_build.go @@ -70,7 +70,7 @@ func (d *dockerfileBuild) Build(re *Request) (*Response, error) { }, nil } -//The same component retains only one build task to perform +// The same component retains only one build task to perform func (d *dockerfileBuild) stopPreBuildJob(re *Request) error { jobList, err := jobc.GetJobController().GetServiceJobs(re.ServiceID) if err != nil { @@ -168,6 +168,13 @@ func (d *dockerfileBuild) runBuildJob(re *Request, buildImageName string) error if len(re.BuildKitArgs) > 0 { container.Args = append(container.Args, re.BuildKitArgs...) } + for key := range re.BuildEnvs { + if strings.HasPrefix(key, "ARG_") { + envKey := strings.Replace(key, "ARG_", "", -1) + container.Args = append(container.Args, fmt.Sprintf("--opt=build-arg:%s=%s", envKey, re.BuildEnvs[key])) + } + } + container.VolumeMounts = mounts podSpec.Containers = append(podSpec.Containers, container) job.Spec = podSpec