CI/CD in Action¶
Make a change in Gogs¶
-
Navigate to your
spring-petclinic
repository's main page (this is theFiles
tab if you are on a different tab such as settings) -
Click on the following sections in order to navigate to the correct file
- src
- main
- resources
- db
- mysql
- data.sql
-
Edit the file by clicking on the pencil icon
-
Change the file to add the pet field of your choice and commit it to your Gogs repository (description and copy and paste box are below image)
-
Make a change using the pet type you want to add (example is a turtle)
Note
The copy and paste box below can be entered on line 24 with
enter
pressed after it to match the image above.Turtle
INSERT IGNORE INTO types VALUES (7, 'turtle');
I want to add Willow, an awesome armadillo, not Yertle the turtle!
If you want to add something other than a turtle as an option, please change
turtle
to that animal (i.e.armadillo
) in the mysql statement above. For the armadillo example, the statement becomes:INSERT IGNORE INTO types VALUES (7, 'armadillo');
-
Type in a commit message (you can make this whatever you want) and commit the change (example copy and paste boxes from image above)
Yertle the turtle
TitleTurtle Time
Extended DescriptionI want to be able to add Yertle the turtle.
-
-
Take note of the git commit message and hash
-
Click on the
Files
tab to go back to the main repository page -
Look at the git commit hash (id)
-
Continuous Integration via OpenShift Pipelines¶
Successfully Run Pipeline via Gogs¶
-
Visit the newly triggered pipeline run in the
Pipelines
menu in the OpenShift UI -
View the pipeline run from the
Details
viewYou can see your user has triggered the
PipelineRun
via your event listener. -
You can see the variables populated with the correct values from Gogs in the
YAML
view of the pipeline run. -
Watch the results of your build pipeline run. It should complete successfully as in the pictures below.
Your pipeline may take a while to run
The pipeline run may take anywhere from 10-25 minutes to complete depending on the current system load. You can see the progress of your build, as well as if any errors occur, via the UI. Thus, by monitoring the UI, you can make sure things are going as planned.
What should you do if your pipeline run ends in failure
If your pipeline run ends in failure, please look at the
Failure
tab (immediately below this message) to get back on track (instead of the defaultSuccess
tab).Pipeline Run Success View Perspective:
Pipeline Run Details View
In the pipeline run
Details
view, you can see the pipeline run succeeded with all tasks having a green check mark. Additionally, observe that the event listener has triggered thePipelineRun
instead of a user this time.Pipeline Run Success Logs Perspective:
Pipeline Run Logs View 1
In the pipeline run
Logs
view, you can also see that the pipeline run tasks all have green check marks. Looking at the last task, you can see that the that the external connection check worked and the PetClinic application is available at the route printed in the logs. Additionally, you can see via the series of tasks marked with green checks that the dev deployment ran successfully and the system cleaned it up and ran the staging deployment successfully to complete the pipeline.Pipeline Run Logs View 2
When you switch to the
deploy-staging
task logs, by clicking on thetask
on the left hand side of theLogs
view of the pipeline run, you see this was an automated build from git since the task prints out theGIT_MESSAGE
that you typed in your commit word for word. (Note: If you chose a different commit message that will show instead of the one displayed in the image above.).Your pipeline failed, here is how to get back on the happy path
-
Please review your
pipelineRun
and see what error caused the failure. -
Make changes to fix the error. (If it's unclear what is causing the error / how to fix it, please ask the instructors for help)
-
Resend the webhook from Gogs to trigger a new
pipelineRun
with the same values as before (see images below for help)-
Click on your webhook from the
Webhooks
section of the repository settings for your Gogs repository fork of thespring-petclinic
repository -
Scroll down to
Recent Deliveries
- Click on the most recent delivery
-
Click
Redelivery
-
-
See Changes in Application¶
-
Navigate to the
Topology
view and open a new tab with your recently deployedstaging
version of the PetClinic application by clickingOpen URL
. -
Navigate to the
Find Owners
tab -
Choose to add a new owner
-
Add the owner with details of your choice
-
Choose to add one of the owner's pets
-
Fill in the pet's details and select the new type of pet you added (turtle for the example)
-
View the newly created pet of the new type (Yertle the turtle for the example)
Summary ¶
In this section, you made a change to your PetClinic application to add a new pet type of your choice and pushed the change to Gogs. This triggered a new pipeline run which built a new image for the application tagged with the git commit hash and displayed the commit message explaining the change the build was implementing. Next, your pipeline deployed this change to OpenShift in development, tested it internally and externally and then rolled it out to staging (where it was also tested automatically). Finally, you visited the application and used the new feature (new type of pet) by adding a pet of that type to a new owner successfully. In other words, you are off the ground and running with "cloud native" CI/CD for your PetClinic application on IBM Z/LinuxONE! Congratulations!!!
Created: April 13, 2021