Skip to content

Commit

Permalink
Fix issue with multiple build tools
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Mar 14, 2024
1 parent 003ecad commit f2a8993
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/apis/jvmbuildservice/v1alpha1/dependencybuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/dependencybuild/buildrecipeyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ")"
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/dependencybuild/dependencybuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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})
}
}
}
Expand Down

0 comments on commit f2a8993

Please sign in to comment.