diff --git a/pipelines/template-build/template-build.yaml b/pipelines/template-build/template-build.yaml index 12f528a5ce..ab3fdcf58c 100644 --- a/pipelines/template-build/template-build.yaml +++ b/pipelines/template-build/template-build.yaml @@ -230,7 +230,7 @@ spec: - name: show-summary taskRef: name: summary - version: "0.1" + version: "0.2" params: - name: pipelinerun-name value: "$(context.pipelineRun.name)" @@ -240,6 +240,9 @@ spec: value: $(params.output-image) - name: build-task-status value: $(tasks.build-container.status) + workspaces: + - name: workspace + workspace: workspace results: - name: IMAGE_URL value: "$(tasks.build-container.results.IMAGE_URL)" diff --git a/task/source-build/0.1/source-build.yaml b/task/source-build/0.1/source-build.yaml index b6842e884b..a55c465124 100644 --- a/task/source-build/0.1/source-build.yaml +++ b/task/source-build/0.1/source-build.yaml @@ -70,6 +70,8 @@ spec: value: "$(results.SOURCE_IMAGE_URL.path)" - name: RESULT_SOURCE_IMAGE_DIGEST value: "$(results.SOURCE_IMAGE_DIGEST.path)" + - name: WS_BUILD_RESULT_FILE + value: "$(workspaces.workspace.path)/source_build_result.json" script: | #!/usr/bin/env bash set -euo pipefail @@ -91,3 +93,5 @@ spec: cat "$RESULT_FILE" | jq -r ".image_url" >"$RESULT_SOURCE_IMAGE_URL" cat "$RESULT_FILE" | jq -r ".image_digest" >"$RESULT_SOURCE_IMAGE_DIGEST" + + cp "$RESULT_FILE" "$WS_BUILD_RESULT_FILE" diff --git a/task/summary/0.2/MIGRATION.md b/task/summary/0.2/MIGRATION.md new file mode 100644 index 0000000000..b699b0bf8d --- /dev/null +++ b/task/summary/0.2/MIGRATION.md @@ -0,0 +1,17 @@ +# Migration from 0.1 to 0.2 + +Task `summary` can be optionally mounted to the shared workspace in order to show source container image URL. Apply the following diff to task `show-summary` in the PipelineRun YAMLs generated by Konflux bot. + +```diff + value: $(params.output-image) + - name: build-task-status + value: $(tasks.build-container.status) ++ workspaces: ++ - name: workspace ++ workspace: workspace + results: + - name: IMAGE_URL + value: "$(tasks.build-container.results.IMAGE_URL)" +``` + +This update to the PipelineRun is optional. The build pipeline can run normally without the mount. diff --git a/task/summary/0.2/README.md b/task/summary/0.2/README.md new file mode 100644 index 0000000000..9473cd76fc --- /dev/null +++ b/task/summary/0.2/README.md @@ -0,0 +1,16 @@ +# summary task + +Summary Pipeline Task. Prints PipelineRun information, removes image repository secret used by the PipelineRun. + +## Parameters +|name|description|default value|required| +|---|---|---|---| +|pipelinerun-name|pipeline-run to annotate||true| +|git-url|Git URL||true| +|image-url|Image URL||true| +|build-task-status|State of build task in pipelineRun|Succeeded|false| + +## Workspaces +|name|description|optional| +|---|---|---| +|workspace|The workspace where source code is included.|true| diff --git a/task/summary/0.2/summary.yaml b/task/summary/0.2/summary.yaml new file mode 100644 index 0000000000..8626b0ab9f --- /dev/null +++ b/task/summary/0.2/summary.yaml @@ -0,0 +1,59 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + labels: + app.kubernetes.io/version: "0.2" + annotations: + tekton.dev/pipelines.minVersion: "0.12.1" + tekton.dev/tags: "appstudio, hacbs" + name: summary +spec: + description: >- + Summary Pipeline Task. Prints PipelineRun information, removes image repository secret used by the PipelineRun. + params: + - name: pipelinerun-name + description: pipeline-run to annotate + - name: git-url + description: Git URL + - name: image-url + description: Image URL + - name: build-task-status + description: State of build task in pipelineRun + # Default Succeeded for backward compatibility + default: Succeeded + workspaces: + - name: workspace + description: The workspace where source code is included. + optional: true + steps: + - name: appstudio-summary + image: quay.io/redhat-appstudio/task-toolset@sha256:931a9f7886586391ccb38d33fd15a47eb03568f9b19512b0a57a56384fa52a3c + # per https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting + # the cluster will set imagePullPolicy to IfNotPresent + # also per direction from Ralph Bean, we want to use image digest based tags to use a cue to automation like dependabot or renovatebot to periodially submit pull requests that update the digest as new images are released. + env: + - name: GIT_URL + value: $(params.git-url) + - name: IMAGE_URL + value: $(params.image-url) + - name: PIPELINERUN_NAME + value: $(params.pipelinerun-name) + - name: BUILD_TASK_STATUS + value: $(params.build-task-status) + - name: SOURCE_BUILD_RESULT_FILE + value: "$(workspaces.workspace.path)/source_build_result.json" + script: | + #!/usr/bin/env bash + echo + echo "Build Summary:" + echo + echo "Build repository: $GIT_URL" + if [ "$BUILD_TASK_STATUS" == "Succeeded" ]; then + echo "Generated Image is in : $IMAGE_URL" + fi + if [ -e "$SOURCE_BUILD_RESULT_FILE" ]; then + url=$(jq -r ".image_url" <"$SOURCE_BUILD_RESULT_FILE") + echo "Generated Source Image is in : $url" + fi + echo + echo End Summary