Skip to content

Commit d23fe4a

Browse files
committed
Add Tekton pipeline definition for OpenShift CI
1 parent fc27bd7 commit d23fe4a

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.tekton/pipeline.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Pipeline
3+
metadata:
4+
name: cicd-final-project-pipeline
5+
spec:
6+
description: "CI/CD Pipeline for the Final Project. It lints, tests, builds, and (later) deploys the application."
7+
workspaces:
8+
- name: shared-workspace
9+
description: "This workspace will be shared by all tasks for source code, etc."
10+
# Potentially a workspace for Docker config if pushing to a secured external registry
11+
# - name: docker-config
12+
# description: "Optional: Docker config for pushing to a secured registry"
13+
# optional: true
14+
15+
params:
16+
- name: repo-url
17+
type: string
18+
description: The URL of the git repository to clone.
19+
default: "https://github.com/galafis/cicd-final-project.git" # Default to the user's repo
20+
- name: repo-revision
21+
type: string
22+
description: The git revision (branch, tag, commit SHA) to checkout.
23+
default: "main"
24+
- name: image-name
25+
type: string
26+
description: Name of the image to be built.
27+
default: "app-image" # This will be prefixed by namespace in OpenShift usually
28+
- name: image-tag
29+
type: string
30+
description: Tag for the image to be built.
31+
default: "latest"
32+
- name: openshift-image-registry-url
33+
type: string
34+
description: "OpenShift internal image registry URL (e.g., image-registry.openshift-image-registry.svc:5000/your-project)"
35+
# This will likely need to be set by the user or discovered when running in OpenShift
36+
default: "image-registry.openshift-image-registry.svc:5000/your-project-name" # Placeholder
37+
38+
tasks:
39+
- name: fetch-repository
40+
taskRef:
41+
name: git-clone
42+
kind: ClusterTask # Assuming git-clone ClusterTask is available
43+
workspaces:
44+
- name: output
45+
workspace: shared-workspace
46+
params:
47+
- name: url
48+
value: $(params.repo-url)
49+
- name: revision
50+
value: $(params.repo-revision)
51+
# - name: sslVerify
52+
# value: "false" # If using self-signed certs for Git
53+
# - name: deleteExisting
54+
# value: "true"
55+
56+
- name: cleanup-workspace # Optional, run before tests if needed
57+
taskRef:
58+
name: cleanup
59+
runAfter: [fetch-repository] # Ensure it runs after fetching
60+
workspaces:
61+
- name: source
62+
workspace: shared-workspace
63+
64+
- name: lint-code
65+
taskRef:
66+
name: lint-code
67+
runAfter: [fetch-repository] # Or cleanup-workspace if that runs first
68+
workspaces:
69+
- name: source
70+
workspace: shared-workspace
71+
params:
72+
- name: python-image
73+
value: python:3.11-slim
74+
75+
- name: run-tests
76+
taskRef:
77+
name: nose-tests # Using the name as required by Task 5
78+
runAfter: [lint-code]
79+
workspaces:
80+
- name: source
81+
workspace: shared-workspace
82+
params:
83+
- name: python-image
84+
value: python:3.11-slim
85+
86+
- name: build-image
87+
taskRef:
88+
name: build-image
89+
runAfter: [run-tests]
90+
workspaces:
91+
- name: source
92+
workspace: shared-workspace
93+
params:
94+
- name: image-url
95+
value: "$(params.openshift-image-registry-url)/$(params.image-name)"
96+
- name: image-tag
97+
value: "$(params.image-tag)"
98+
- name: dockerfile
99+
value: "./Dockerfile" # Assuming Dockerfile is in root of repo
100+
- name: context
101+
value: "." # Context is the root of the repo
102+
# If pushing to OpenShift internal registry and Kaniko needs service account with push rights:
103+
# This might require a specific serviceAccountName for the PipelineRun
104+
# or specific credentials mounted if Kaniko task doesn't handle it automatically.
105+

0 commit comments

Comments
 (0)