This repo is a sample Tekton pipeline that builds and deploys the Spring PetClinic sample Spring Boot application on OpenShift. This demo creates:
- 3 namespaces for CI/CD, DEV and STAGE projects
- A sample Tekton pipeline
- Gogs git server (username/password:
gogs
/gogs
) - Sonatype Nexus (username/password:
admin
/admin123
) - SonarQube (username/password:
admin
/admin
) - Report repository for test and project generated reports
- Imports Spring PetClinic repository into Gogs git server
- Adds a webhook to
spring-petclinic
repository in Gogs to start the Tekton pipeline
On every push to the spring-petclinic
git repository on Gogs git server, the following steps are executed within the pipeline:
- Code is cloned from Gogs and the unit-tests are run
- Application is packaged as a JAR and pushed to Sonatype Nexus snapshot repository
- In parallel, the code is analyzed by SonarQube for anti-patterns, code coverage and potential bugs
- A container image (spring-petclinic:latest) is built using the Source-to-Image for Java apps, and pushed to OpenShift internal registry
- Application image is deployed with a rolling update
Currently valid in openshift 4.5.8 and tekton 0.4.0, if you use tekton 0.5.0, you need to repair two files, see tekton-0.5.0/
-
Get an OpenShift cluster via https://try.openshift.com
-
Install OpenShift Pipelines Operator
-
Download OpenShift CLI and Tekton CLI
-
Deploy the demo
$ git clone https://github.com/siamaksade/tekton-cd-demo $ cd tekton-cd-demo use "demo" prefix name with storage $ ./deploy.sh install or use custom prefix name without storage $ ./deploy.sh install --project-prefix myapp --ephemeral
-
Start the deploy pipeline by making a change in the
spring-petclinic
Git repository on Gogs, or run the following:run pipeline with storage $ ./deploy.sh start or run pipeline use custom prefix without stroage $ ./deploy.sh start --project-prefix myapp --ephemeral
-
uninstall the demo Delete the created projects, such as demo-cicd, demo-dev, demo-stage
-
Check pipeline run logs
$ tkn pipeline logs petclinic-deploy-dev -f NAMESPACE