Lab 4.4: Link and Test Projects

Keyboard Time: 5 mins, Automation Wait Time: 3 mins

Scenarios: Instructor-Led, Self-Paced

Target Outcomes
  1. Link the projects using a scheduled pipeline.
Tip
These methods of linking the projects are loosely coupled. The benefits of this approach are described in Loose Project Coupling

Scheduled Pipeline Model

  1. In ‘yourpersonalgroup/world-greetings-env-1’ Click CI/CD => Schedules

  2. On the upper right of the page, Click New schedule (button)

  3. Under Description Type CheckForNewContainerVersion

  4. Leave all other items at their defaults.

  5. Near the bottom left of the page, Click Save pipeline schedule

    Normally you would take time to create one or more schedules specific to your desired frequency.

  6. On the right of CheckForNewContainerVersion Click [the play button]

  7. On the left navigation, Click CI/CD => Pipelines

  8. On the latest pipeline Click [the Status badge] or [the pipeline #]

  9. Wait for the pipeline to complete.

  10. If you did not perform any extra builds on the Application Project, the “deploy” job will have a failed status and the pipeline will have a status of “Passed”

Failed 'deploy' job is OK
The deploy job status is ‘failed’ because no child pipeline jobs are scheduled because there has not been a new container published since the last run (and no changes were made to the Environment Deployment Project package manifests). GitLab considers it a failure when a parent pipeline fails to create a child pipeline, but we’ve marked this job “allowed_to_fail” which gives the Pipeline status of “Passed” (because it is the most efficient way to only run the manifest builds when there is actually a change we care about.)
Accomplished Outcomes
  1. Link the projects using a scheduled pipeline.
Instructor Led Classroom
If you are in an Instructor-Led course, do not do [Extra Credit] exercises after this point.

[Extra Credit] Pipeline Subscription Model

Instructor Led Classroom
If you are in an Instructor-Led course, do not do [Extra Credit] exercises including this one.

Pipeline subscriptions allow an Environment Deployment Project to trigger nearly immediately after the Application Project completes a build.

  1. Open ‘yourpersonalgroup/hello-world’

  2. In the browser URL bar, copy the URL path without the domain. For example if the browser url is https://gitlab.com/group1/myuser/hello-world you would copy ‘group1/myuser/hello-world ’

  3. In a NEW browser tab, open ‘yourpersonalgroup/world-greetings-env-1’

  4. Click Settings => CI/CD

  5. Next to Pipeline subscriptions, Click Expand

  6. Under Project path, Paste [the path copied from the hello-world project]

  7. Click Subscribe

  8. Next to Pipeline subscriptions, Click Expand

[Extra Credit] Run Pipeline With NEXTVERSIONTOUSE Variable To Specify Version

Warning
If you are in an instructor-led workshop, please ask the instructor before performing this lab as it could affect workshop timing or the stability of additional assigned labs. If used in production this method would not be paired with any auto-update mechanism above because that mechanism would dynamically install the latest.

This method can also be used to roll back an environment.

  1. Open ‘yourpersonalgroup/world-greetings-env-1’
  2. On the left navigation, Click CI/CD => Pipelines
  3. In the upper right of the page, Click Run pipeline (button)
  4. Under Variables, Type NEXTVERSIONTOUSE over ‘Input variable key’
  5. On the same line, Type 0.0.1 over ‘Input variable value’
  6. In the lower left of the page Click Run pipeline (button)
  7. Wait for the pipeline to complete successfully.
  8. In a NEW browser tab, open ‘yourpersonalgroup/world-greetings-env-1’ in the Web IDE.
  9. In the files list on the left Click manifests > hello-world.staging.yaml
  10. Search for - image:
  11. The image reference should point to the version “0.0.1”
  12. In the left navigation Click CI/CD => Pipelines
  13. Find the last non-skipped pipeline and Click it’s [Status badge] or [Pipeline #] to open the pipeline.
  14. Expand the Downstream pipeline with the great than arrow (>).
  15. Next to the update-production-manifests job, Click [the play button]
  16. Wait until the update-production-manifests job has a green check next to it.
  17. Switch back to [the Web IDE tab]
  18. Click [the browser refresh button]
  19. In the files list on the left Click manifests > hello-world.production.yaml
  20. Search for - image:
  21. The image reference and version tag should match the staging manifest (“0.0.1”)

[Extra Credit] Create an MR with NEXTVERSIONTOUSE File To Specify Version

Warning
If you are in an instructor-led workshop, please ask the instructor before performing this lab as it could affect workshop timing or the stability of additional assigned labs. This section is just to let you know that you can create a Merge Request that creates or updates a file called NEXTVERSIONTOUSE that only contains the desired version on the first and only line in the file. This enables MR review by as many people as necessary to gather approvals before environment deployments are performed. If you have previously done MRs in GitLab, you could do this procedure to experience an MR approval based workflow in an Environment Deployment Project.