generated from nyu-devops/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from CSCI-GA-2820-FA23-001/yantao_dev
Create pipeline files and add clone to the pipeline
- Loading branch information
Showing
4 changed files
with
257 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
creationTimestamp: '2023-12-03T20:32:31Z' | ||
generation: 2 | ||
managedFields: | ||
- apiVersion: tekton.dev/v1 | ||
fieldsType: FieldsV1 | ||
fieldsV1: | ||
'f:spec': | ||
.: {} | ||
'f:finally': {} | ||
'f:params': {} | ||
'f:tasks': {} | ||
'f:workspaces': {} | ||
manager: Mozilla | ||
operation: Update | ||
time: '2023-12-03T21:55:43Z' | ||
name: cd-pipeline | ||
# namespace: devops-products | ||
resourceVersion: '1583706109' | ||
uid: 6ffec68d-1efc-4ae2-9811-9815aae271fb | ||
spec: | ||
params: | ||
- description: The URL to the git repo | ||
name: GIT_REPO | ||
type: string | ||
- default: master | ||
description: The reference (branch or ref) | ||
name: GIT_REF | ||
type: string | ||
tasks: | ||
- name: git-clone | ||
params: | ||
- name: url | ||
value: $(params.GIT_REPO) | ||
- name: revision | ||
value: $(params.GIT_REF) | ||
- name: refspec | ||
value: '' | ||
- name: submodules | ||
value: 'true' | ||
- name: depth | ||
value: '1' | ||
- name: sslVerify | ||
value: 'true' | ||
- name: crtFileName | ||
value: ca-bundle.crt | ||
- name: subdirectory | ||
value: '' | ||
- name: sparseCheckoutDirectories | ||
value: '' | ||
- name: deleteExisting | ||
value: 'true' | ||
- name: httpProxy | ||
value: '' | ||
- name: httpsProxy | ||
value: '' | ||
- name: noProxy | ||
value: '' | ||
- name: verbose | ||
value: 'true' | ||
- name: gitInitImage | ||
value: >- | ||
registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:1a50511583fc02a27012d17d942e247813404104ddd282d7e26f99765174392c | ||
- name: userHome | ||
value: /home/git | ||
taskRef: | ||
kind: ClusterTask | ||
name: git-clone | ||
workspaces: | ||
- name: output | ||
workspace: pipeline-workspace | ||
workspaces: | ||
- name: pipeline-workspace | ||
optional: false | ||
finally: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
amespace: devops-products | ||
name: green | ||
# namespace: devops-products | ||
labels: | ||
app.kubernetes.io/version: "0.1" | ||
annotations: | ||
tekton.dev/categories: Testing | ||
tekton.dev/pipelines.minVersion: "0.17.0" | ||
tekton.dev/tags: python, green | ||
tekton.dev/displayName: "green tests" | ||
tekton.dev/platforms: "linux/amd64" | ||
spec: | ||
workspaces: | ||
- name: source | ||
description: >- | ||
This task can be used to perform unit tests with green. #magic___^_^___line If you define a secret with the key `database_uri` it will create an environment variable named DATABASE_URI that can be used to connect to a test database. | ||
params: | ||
- name: ARGS | ||
description: The additional arguments to be used with green | ||
type: string | ||
default: "-vvv --processes=1 --run-coverage --minimum-coverage=95" | ||
- name: SECRET_NAME | ||
description: The name of the secret containing a database_uri key | ||
type: string | ||
default: "postgres-creds" | ||
- name: SECRET_KEY | ||
description: The name of the key that contains the database uri | ||
type: string | ||
default: "database_uri" | ||
steps: | ||
- name: green | ||
image: python:3.11-slim | ||
workingDir: $(workspaces.source.path) | ||
env: | ||
- name: DATABASE_URI | ||
valueFrom: | ||
secretKeyRef: | ||
name: $(params.SECRET_NAME) | ||
key: $(params.SECRET_KEY) | ||
script: | | ||
#!/bin/bash | ||
set -e | ||
echo "***** Installing dependencies *****" | ||
python -m pip install --upgrade pip wheel | ||
pip install -qr requirements.txt | ||
echo "***** Running Tests *****" | ||
green $(params.ARGS) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
# namespace: devops-products | ||
name: deploy-image | ||
labels: | ||
app.kubernetes.io/version: "0.1" | ||
annotations: | ||
tekton.dev/categories: Deployment | ||
tekton.dev/pipelines.minVersion: "0.17.0" | ||
tekton.dev/tags: openshift, deploy | ||
tekton.dev/displayName: "deploy image" | ||
tekton.dev/platforms: "linux/amd64" | ||
spec: | ||
workspaces: | ||
- name: source | ||
description: >- | ||
This task will update the deployment.yaml with the latest image name and then apply that yaml file and it's service file. | ||
params: | ||
- name: old_image_name | ||
description: The fully qualified name of the old image to replace | ||
type: string | ||
- name: image_name | ||
description: The fully qualified name of the new image to deploy | ||
type: string | ||
- name: manifest_dir | ||
description: The directory in source that contains yaml manifests | ||
type: string | ||
default: "k8s" | ||
steps: | ||
- name: deploy | ||
image: quay.io/openshift/origin-cli:latest | ||
workingDir: /workspace/source | ||
command: ["/bin/bash", "-c"] | ||
args: | ||
- |- | ||
#!/bin/bash | ||
set -e | ||
echo Applying manifests in $(inputs.params.manifest_dir) directory | ||
echo "********************* DEPLOYMENT ***********************" | ||
echo "Deploying $(inputs.params.image_name) ..." | ||
sed -i 's|'"$(inputs.params.old_image_name)"'|'"$(inputs.params.image_name)"'|g' $(inputs.params.manifest_dir)/deployment.yaml | ||
cat $(inputs.params.manifest_dir)/deployment.yaml | ||
echo "************************************************************" | ||
echo "OC APPLY..." | ||
oc apply -f $(inputs.params.manifest_dir)/deployment.yaml | ||
oc apply -f $(inputs.params.manifest_dir)/service.yaml | ||
echo "************************************************************" | ||
sleep 3 | ||
echo "Pods:" | ||
oc get pods | ||
echo "" | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
# namespace: devops-products | ||
name: apply-manifests | ||
labels: | ||
app.kubernetes.io/version: "0.1" | ||
annotations: | ||
tekton.dev/categories: Deployment | ||
tekton.dev/pipelines.minVersion: "0.17.0" | ||
tekton.dev/tags: openshift, deploy | ||
tekton.dev/displayName: "deploy" | ||
tekton.dev/platforms: "linux/amd64" | ||
spec: | ||
workspaces: | ||
- name: source | ||
description: >- | ||
This task will deploy all of the yaml files in the manifest folder. | ||
params: | ||
- name: manifest_dir | ||
description: The directory in source that contains yaml manifests | ||
type: string | ||
default: "k8s" | ||
steps: | ||
- name: apply | ||
image: quay.io/openshift/origin-cli:latest | ||
workingDir: /workspace/source | ||
command: ["/bin/bash", "-c"] | ||
args: | ||
- |- | ||
echo Applying manifests in $(inputs.params.manifest_dir) directory | ||
oc apply -f $(inputs.params.manifest_dir) | ||
echo ----------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# apiVersion: v1 | ||
# kind: Namespace | ||
# metadata: | ||
# name: devops-products | ||
# labels: | ||
# name: products | ||
# --- | ||
|
||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
# namespace: devops-products | ||
name: pipeline-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 500Mi | ||
volumeMode: Filesystem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters