Skip to content

Commit

Permalink
Merge pull request #853 from tkdchen/STONEBLD-1608-show-source-image-…
Browse files Browse the repository at this point in the history
…in-summary-rework

Show source image URL in summary
  • Loading branch information
tkdchen authored Mar 13, 2024
2 parents 6505cbe + 671dddc commit 2b39b1a
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pipelines/template-build/template-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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)"
Expand Down
4 changes: 4 additions & 0 deletions task/source-build/0.1/source-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
17 changes: 17 additions & 0 deletions task/summary/0.2/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 16 additions & 0 deletions task/summary/0.2/README.md
Original file line number Diff line number Diff line change
@@ -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|
59 changes: 59 additions & 0 deletions task/summary/0.2/summary.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2b39b1a

Please sign in to comment.