我们想使用 Maven 构建一个基于 Spring Boot 的项目。我们在 Tekton Hub 上找到了 Maven 任务,并且已经有一个正在运行的管道。在一个缩短的版本中,我们pipeline.yml
看起来像这样:
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: buildpacks-test-pipeline
spec:
params:
- name: SOURCE_URL
type: string
description: A git repo url where the source code resides.
- name: SOURCE_REVISION
description: The branch, tag or SHA to checkout.
default: ""
workspaces:
- name: maven-settings
- name: source-workspace
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: source-workspace
params:
- name: url
value: "$(params.SOURCE_URL)"
- name: revision
value: "$(params.SOURCE_REVISION)"
- name: subdirectory
value: ""
- name: deleteExisting
value: "true"
- name: maven
taskRef:
name: maven
runAfter:
- fetch-repository
params:
- name: GOALS
value:
- package
workspaces:
- name: source
workspace: source-workspace
- name: maven-settings
workspace: maven-settings
PipelineRun 定义为:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: buildpacks-test-pipeline-run-
spec:
pipelineRef:
name: buildpacks-test-pipeline
workspaces:
- name: maven-settings
emptyDir: {}
- name: source-workspace
subPath: source
persistentVolumeClaim:
claimName: source-pvc
params:
- name: SOURCE_URL
value: https://gitlab.com/jonashackt/microservice-api-spring-boot
- name: SOURCE_REVISION
value: 3c4131f8566ef157244881bacc474543ef96755d
source-pvc
PersistentVolumeClaim 定义为:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: source-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
我们的项目正在构建中,但是当我们启动另一个 PipelineRun 时,任务会一遍又一遍地下载项目的所有 Maven 依赖项:
Tekton Hub 的 Maven 任务https://hub.tekton.dev/tekton/task/maven似乎不支持使用缓存。尽管如此,我们如何缓存?