Skip to content

Commit

Permalink
Remove workspace from prebuildgit
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc committed Dec 24, 2024
1 parent bfc2f8b commit a4918b4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
31 changes: 27 additions & 4 deletions deploy/tasks/pre-build-git.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions pkg/reconciler/dependencybuild/buildrecipeyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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...)
Expand Down Expand Up @@ -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)

Check failure on line 820 in pkg/reconciler/dependencybuild/buildrecipeyaml.go

View workflow job for this annotation

GitHub Actions / Lint

printf: fmt.Printf format %#v reads arg #2, but call has 1 arg (govet)

Check failure on line 820 in pkg/reconciler/dependencybuild/buildrecipeyaml.go

View workflow job for this annotation

GitHub Actions / Golang Unit tests

fmt.Printf format %#v reads arg #2, but call has 1 arg
index += 1
ps.Tasks[index].Params = append(ps.Tasks[index].Params, tektonpipeline.Param{
Name: i.Name,
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/dependencybuild/dependencybuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a4918b4

Please sign in to comment.