diff --git a/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go b/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go index 5d9bb78349..37ee604602 100644 --- a/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go +++ b/pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go @@ -77,6 +77,7 @@ type BuildAttempt struct { type PreBuildImage struct { BaseBuilderImage string `json:"baseBuilderImage,omitempty"` BuiltImageDigest string `json:"builtImageDigest,omitempty"` + Tool string `json:"tool,omitempty"` } type BuildPipelineRun struct { diff --git a/pkg/reconciler/dependencybuild/buildrecipeyaml.go b/pkg/reconciler/dependencybuild/buildrecipeyaml.go index 5e457bcc93..c8f4c6a7dd 100644 --- a/pkg/reconciler/dependencybuild/buildrecipeyaml.go +++ b/pkg/reconciler/dependencybuild/buildrecipeyaml.go @@ -198,7 +198,7 @@ func createPipelineSpec(tool string, commitTime int64, jbsConfig *v1alpha12.JBSC secretVariables = append(secretVariables, v1.EnvVar{Name: "GIT_DEPLOY_TOKEN", ValueFrom: &v1.EnvVarSource{SecretKeyRef: &v1.SecretKeySelector{LocalObjectReference: v1.LocalObjectReference{Name: v1alpha12.GitRepoSecretName}, Key: v1alpha12.GitRepoSecretKey, Optional: &trueBool}}}) } - preBuildImage := existingImages[recipe.Image] + preBuildImage := existingImages[recipe.Image+"-"+recipe.Tool] preBuildImageRequired := preBuildImage == "" if preBuildImageRequired { preBuildImage = "$(tasks." + PreBuildTaskName + ".results." + PreBuildImageDigest + ")" diff --git a/pkg/reconciler/dependencybuild/dependencybuild.go b/pkg/reconciler/dependencybuild/dependencybuild.go index 2061c3c7b2..73328e210d 100644 --- a/pkg/reconciler/dependencybuild/dependencybuild.go +++ b/pkg/reconciler/dependencybuild/dependencybuild.go @@ -564,7 +564,7 @@ func (r *ReconcileDependencyBuild) handleStateBuilding(ctx context.Context, log // TODO: set owner, pass parameter to do verify if true, via an annoaton on the dependency build, may eed to wait for dep build to exist verify is an optional, use append on each step in build recipes preBuildImages := map[string]string{} for _, i := range db.Status.PreBuildImages { - preBuildImages[i.BaseBuilderImage] = i.BuiltImageDigest + preBuildImages[i.BaseBuilderImage+"-"+i.Tool] = i.BuiltImageDigest } pr.Spec.Timeouts = &tektonpipeline.TimeoutFields{ Pipeline: &v12.Duration{Duration: time.Hour * 3}, @@ -642,7 +642,7 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co //this is a big perfomance optimisation, as it can be re-used on subsequent attempts alreadyExists := false for _, i := range db.Status.PreBuildImages { - if i.BaseBuilderImage == attempt.Recipe.Image { + if i.BaseBuilderImage == attempt.Recipe.Image && i.Tool == attempt.Recipe.Tool { alreadyExists = true } } @@ -658,7 +658,7 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co if preBuildSuccess { for _, res := range tr.Status.Results { if res.Name == PreBuildImageDigest && res.Value.StringVal != "" { - db.Status.PreBuildImages = append(db.Status.PreBuildImages, v1alpha1.PreBuildImage{BaseBuilderImage: attempt.Recipe.Image, BuiltImageDigest: res.Value.StringVal}) + db.Status.PreBuildImages = append(db.Status.PreBuildImages, v1alpha1.PreBuildImage{BaseBuilderImage: attempt.Recipe.Image, BuiltImageDigest: res.Value.StringVal, Tool: attempt.Recipe.Tool}) } } }