Skip to content

Instantly share code, notes, and snippets.

@making
Last active July 5, 2022 06:52
Show Gist options
  • Save making/06fc2dbbc0b955773240ae8008644098 to your computer and use it in GitHub Desktop.
Save making/06fc2dbbc0b955773240ae8008644098 to your computer and use it in GitHub Desktop.
unit-test (Tekton)
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: unit-test-run-
spec:
pipelineRef:
name: unit-test
workspaces:
- name: cache
persistentVolumeClaim:
claimName: unit-test-pipeline-cache
# kubectl apply -f unit-test.yml
# kubectl create -f unit-test-run.yml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: unit-test-pipeline-cache
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: unit-test
spec:
workspaces:
- name: cache
tasks:
- name: mvn-test
workspaces:
- name: cache
workspace: cache
taskSpec:
workspaces:
- name: cache
steps:
- name: git-clone
image: alpine/git
workingDir: /workspace
script: |
#!/usr/bin/env sh
git clone https://github.com/making/hello-servlet
- name: mvn-test
image: eclipse-temurin:17
workingDir: /workspace
script: |
#!/bin/bash
set -ex
cd hello-servlet
rm -rf ~/.m2
mkdir -p $(workspaces.cache.path)/.m2
ln -fs $(workspaces.cache.path)/.m2 ~/.m2
./mvnw test -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment