From a4918b427ac57e0b88cf56842cc5bdf14d9a6ca3 Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Tue, 24 Dec 2024 10:37:49 +0000 Subject: [PATCH] Remove workspace from prebuildgit --- deploy/tasks/pre-build-git.yaml | 31 ++++++++++++++++--- .../dependencybuild/buildrecipeyaml.go | 17 ++++++++++ .../dependencybuild/dependencybuild.go | 2 +- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/deploy/tasks/pre-build-git.yaml b/deploy/tasks/pre-build-git.yaml index ee38332c9..272ed7874 100644 --- a/deploy/tasks/pre-build-git.yaml +++ b/deploy/tasks/pre-build-git.yaml @@ -13,6 +13,12 @@ spec: description: |- Sets up pre-build for pushing the source. params: + - name: IMAGE_URL + description: Reference to the OCI archive + type: string + - name: PRE_BUILD_IMAGE_DIGEST + description: Digest to use + type: string - name: NAME description: Name of the pipeline run (i.e. unique dependency build name) type: string @@ -46,11 +52,28 @@ spec: results: - name: GIT_ARCHIVE description: Git archive information - workspaces: - - description: The git repo will be cloned onto the volume backing this Workspace. - name: source - mountPath: /var/workdir + volumes: + - name: workdir + emptyDir: {} + stepTemplate: + volumeMounts: + - mountPath: /var/workdir + name: workdir steps: + - name: restore-trusted-artifact + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af + script: | + echo "Restoring artifacts to workspace" + URL=$IMAGE_URL + DIGEST=$PRE_BUILD_IMAGE_DIGEST + AARCHIVE=$(oras manifest fetch $ORAS_OPTIONS $URL@$DIGEST | jq --raw-output '.layers[0].digest') + echo "URL $URL DIGEST $DIGEST AARCHIVE $AARCHIVE" + use-archive oci:$URL@$AARCHIVE=/var/workdir/ + env: + - name: PRE_BUILD_IMAGE_DIGEST + value: $(params.PRE_BUILD_IMAGE_DIGEST) + - name: IMAGE_URL + value: $(params.IMAGE_URL) - name: create-pre-build-source image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) securityContext: diff --git a/pkg/reconciler/dependencybuild/buildrecipeyaml.go b/pkg/reconciler/dependencybuild/buildrecipeyaml.go index b17d8fdce..b0fdcafa4 100644 --- a/pkg/reconciler/dependencybuild/buildrecipeyaml.go +++ b/pkg/reconciler/dependencybuild/buildrecipeyaml.go @@ -273,6 +273,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi preBuildImageRequired := preBuildImage == "" if preBuildImageRequired { preBuildImage = "$(tasks." + PreBuildTaskName + ".results." + PipelineResultPreBuildImageDigest + ")" + //runAfter = []string{PreBuildTaskName} runAfter = []string{PreBuildGitTaskName} } runAfterBuild = append(runAfter, BuildTaskName) @@ -452,6 +453,20 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi StringVal: imageId, }, }, + { + Name: "IMAGE_URL", + Value: tektonpipeline.ParamValue{ + Type: tektonpipeline.ParamTypeString, + StringVal: registryArgsWithDefaults(jbsConfig, imageId+"-pre-build-image"), + }, + }, + { + Name: "PRE_BUILD_IMAGE_DIGEST", + Value: tektonpipeline.ParamValue{ + Type: tektonpipeline.ParamTypeString, + StringVal: "$(tasks." + PreBuildTaskName + ".results." + PipelineResultPreBuildImageDigest + ")", + }, + }, { Name: "GIT_IDENTITY", Value: tektonpipeline.ParamValue{ @@ -503,6 +518,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi }, }, }} + fmt.Printf("### prebuildgit %#v \n", pipelinePreBuildGitTask) ps.Tasks = append(pipelineGitTask, ps.Tasks...) ps.Tasks = append(pipelinePreBuildTask, ps.Tasks...) ps.Tasks = append(pipelinePreBuildGitTask, ps.Tasks...) @@ -801,6 +817,7 @@ use-archive oci:$URL@$AARCHIVE=%s`, orasOptions, registryArgsWithDefaults(jbsCon ps.Tasks[index].Params = append(ps.Tasks[index].Params, tektonpipeline.Param{ Name: i.Name, Value: value}) + fmt.Printf("### index %s and params %#v \n ", ps.Tasks[index].Params) index += 1 ps.Tasks[index].Params = append(ps.Tasks[index].Params, tektonpipeline.Param{ Name: i.Name, diff --git a/pkg/reconciler/dependencybuild/dependencybuild.go b/pkg/reconciler/dependencybuild/dependencybuild.go index ce97587aa..ab5925d54 100644 --- a/pkg/reconciler/dependencybuild/dependencybuild.go +++ b/pkg/reconciler/dependencybuild/dependencybuild.go @@ -668,7 +668,7 @@ func (r *ReconcileDependencyBuild) handleStateBuilding(ctx context.Context, db * log.Info(fmt.Sprintf("handleStateBuilding: pipelinerun %s:%s already exists, not retrying", pr.Namespace, pr.Name)) return reconcile.Result{}, nil } - r.eventRecorder.Eventf(db, v1.EventTypeWarning, "PipelineRunCreationFailed", "The DependencyBuild %s/%s failed to create its build pipeline run", db.Namespace, db.Name) + r.eventRecorder.Eventf(db, v1.EventTypeWarning, "PipelineRunCreationFailed", "The DependencyBuild %s/%s failed to create its build pipeline run with %#v", db.Namespace, db.Name, err) return reconcile.Result{}, err } return reconcile.Result{}, r.client.Status().Update(ctx, db)