Add custom multibranch pipeline runner.

This commit is contained in:
James Pace 2023-02-15 23:38:12 -05:00
parent fb84fe1324
commit 3ed31d4bcd
4 changed files with 76 additions and 9 deletions

View File

@ -0,0 +1,41 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-branch-pipeline-deployment
namespace: j7s-ci
labels:
app: test-branch-pipeline
spec:
replicas: 1
selector:
matchLabels:
app: test-branch-pipeline
template:
metadata:
labels:
app: test-branch-pipeline
spec:
volumes:
- name: ssh-volume
secret:
secretName: git-credentials
containers:
- name: branch-pipeline
image: 192.168.1.149:8443/j7s_branch_trigger:0.2
command: ["/bin/bash", "-c"]
volumeMounts:
- mountPath: /ssh-volume
name: ssh-volume
env:
- name: J7S_REPO
value: "ssh://git.jpace121.net:2222/tests/job-test"
- name: J7S_URL
value: http://el-test-pipeline-listener.j7s-ci.svc.cluster.local:8080
args:
- |
cp -r /ssh-volume ~/.ssh
chmod 700 ~/.ssh
chmod -R 400 ~/.ssh/*
j7s_branch_trigger

View File

@ -12,6 +12,9 @@ spec:
description: Shared data. description: Shared data.
- name: git-credentials - name: git-credentials
description: tekton git credentials description: tekton git credentials
params:
- name: hash
default: HEAD
tasks: tasks:
- name: fetch-repo - name: fetch-repo
workspaces: workspaces:
@ -22,10 +25,10 @@ spec:
params: params:
- name: url - name: url
value: ssh://git.jpace121.net:2222/tests/job-test value: ssh://git.jpace121.net:2222/tests/job-test
- name: branch - name: hash
value: master value: $(params.hash)
taskRef: taskRef:
name: j7s-git-clone name: j7s-git-clone-hash
- name: cat-readme - name: cat-readme
runAfter: ["fetch-repo"] runAfter: ["fetch-repo"]
workspaces: workspaces:

View File

@ -0,0 +1,23 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: j7s-git-clone-hash
namespace: j7s-ci
spec:
workspaces:
- name: output
- name: ssh-directory
params:
- name: url
- name: hash
steps:
- image: 192.168.1.149:8443/gitssh:latest
script: |
set -x
cp -r $(workspaces.ssh-directory.path) ~/.ssh
chmod 700 ~/.ssh
chmod -R 400 ~/.ssh/*
git clone $(params.url) $(workspaces.output.path)
cd $(workspaces.output.path)
git checkout $(params.hash)

View File

@ -23,8 +23,8 @@ metadata:
namespace: j7s-ci namespace: j7s-ci
spec: spec:
params: params:
- name: pr-id - name: hash
value: $(body.pr-id) value: $(body.hash)
--- ---
apiVersion: triggers.tekton.dev/v1beta1 apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate kind: TriggerTemplate
@ -33,7 +33,7 @@ metadata:
namespace: j7s-ci namespace: j7s-ci
spec: spec:
params: params:
- name: pr-id - name: hash
resourcetemplates: resourcetemplates:
- apiVersion: tekton.dev/v1beta1 - apiVersion: tekton.dev/v1beta1
kind: PipelineRun kind: PipelineRun
@ -41,10 +41,10 @@ spec:
generateName: test-pipeline- generateName: test-pipeline-
spec: spec:
pipelineRef: pipelineRef:
name: test-pipeline name: test-report-pipeline
params: params:
- name: pr-id - name: hash
value: "$(tt.params.pr-id)" value: "$(tt.params.hash)"
workspaces: workspaces:
- name: shared-data - name: shared-data
volumeClaimTemplate: volumeClaimTemplate: