Added tekton pipelines

This commit is contained in:
2020-04-25 19:18:33 +01:00
parent 24f184e4c5
commit 5a1e9fa22c
25 changed files with 3597 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: docker-build-and-publish
namespace: tekton-pipelines
spec:
params:
- name: DOCKERFILE
type: string
description: The path to the dockerfile to build
default: /Dockerfile
- name: CONTEXT
type: string
description: The build context used by Docker.
default: ./
- name: IMAGE
type: string
description: Name (reference) of the image to build.
- name: EXTRA_ARGS
type: string
default: ""
resources:
inputs:
- name: src
type: git
results:
- name: IMAGE_DIGEST
description: Digest of the image just built.
steps:
- name: build-and-push
workingDir: /workspace/src
image: gcr.io/kaniko-project/executor:latest
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker
command:
- /kaniko/executor
- $(params.EXTRA_ARGS)
- --dockerfile=/workspace/src/$(params.DOCKERFILE)
- --context=/workspace/src/$(params.CONTEXT)
- --destination=$(params.IMAGE)
- --oci-layout-path=/workspace/src/image-digest
- --digest-file=/tekton/results/IMAGE_DIGEST
securityContext:
runAsUser: 0

View File

@@ -0,0 +1,14 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: kubectl-apply-files
namespace: tekton-pipelines
spec:
params:
- name: DIRECTORY
description: Directory of kubernetes manifest files
steps:
- name: kubectl-apply
image: gcr.io/cloud-builders/kubectl
script: |
kubectl apply --recursive -f $(params.DIRECTORY)

View File

@@ -0,0 +1,14 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: kubectl-apply-inline
namespace: tekton-pipelines
spec:
params:
- name: MANIFEST
description: Content of the resource to deploy
steps:
- name: kubectl-apply
image: gcr.io/cloud-builders/kubectl
script: |
echo "$(params.MANIFEST)" | kubectl apply -f -

View File

@@ -0,0 +1,25 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: kubectl-patch-image
namespace: tekton-pipelines
spec:
params:
- name: NAMESPACE
default: "default"
description: The namespace the kubernetes resource is in
- name: RESOURCE_TYPE
default: "deployment"
description: The type of Kubernetes resource
- name: NAME
description: The name of the resource
- name: CONTAINER_NAME
description: The name of the container to patch
default: "*" # defaults to updating _all_ containers
- name: IMAGE
description: The new image to use
steps:
- name: kubectl-patch-image
image: gcr.io/cloud-builders/kubectl
script: |
kubectl --namespace $(params.NAMESPACE) set image $(params.RESOURCE_TYPE) $(params.NAME) $(params.CONTAINER_NAME)=$(params.IMAGE)

19
tekton/tasks/make.yaml Normal file
View File

@@ -0,0 +1,19 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: make
namespace: tekton-pipelines
spec:
params:
- name: TARGET
description: The make target to run
resources:
inputs:
- name: src
type: git
steps:
- name: make
workingDir: /workspace/src
image: docker.cloud.cluster.fun/averagemarcus/ci-builder:latest
script: |
make --dry-run -t $(params.TARGET) &> /dev/null && make $(params.TARGET) || echo "No '$(params.TARGET)' target found, skipping"

View File

@@ -0,0 +1,27 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: pr-status
namespace: tekton-pipelines
spec:
params:
- name: REPO
description: The name of the repo
- name: SHA
description: The git SHA to update the status of
- name: STATE
description: The state to set the status to (pending, success, error, failure or warning)
default: "pending"
steps:
- name: pr-status-update
image: docker.cloud.cluster.fun/averagemarcus/gitea-pr-state:latest
env:
- name: ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: gitea-access-token
key: access-token
args:
- "$(params.REPO)"
- "$(params.SHA)"
- "$(params.STATE)"