Skip to content

Commit

Permalink
Merge pull request #197 from puzzle/prepare-labs
Browse files Browse the repository at this point in the history
Prepare labs
  • Loading branch information
elatella authored Sep 25, 2023
2 parents acb459d + bb023a9 commit bcacccf
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 38 deletions.
1 change: 1 addition & 0 deletions content/en/docs/01/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ You can also use the main navigation. `Menu` --> `Projects` --> `Create new proj

* **Git repository URL**: https://github.com/appuio/example-spring-boot-helloworld.git
* **Username & Password**: Leave empty
* **Project name**: Choose a unique name, e.g. prefix with your username
* **Project URL**: <!-- TODO -->
* **Visibility Level**: Private

Expand Down
4 changes: 2 additions & 2 deletions content/en/docs/02/pipeline_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Commit and push the changes.
```bash
git add .
git commit -m "Add minimal pipeline"
git push origin master
git push origin main
```

{{% /details %}}
Expand Down Expand Up @@ -89,7 +89,7 @@ Jobs are ...

## Task {{% param sectionnumber %}}.3: Check pipeline execution

Go to your GitLab project and check the pipelines under `CI/CD` --> `Pipelines`.
Go to your GitLab project and check the pipelines under `Build` --> `Pipelines`.

The pipeline at the top of the table is the one that has been triggered by your latest commit.

Expand Down
10 changes: 5 additions & 5 deletions content/en/docs/04/tooling_images.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ Using freely available Container Images is risky. Be aware of the security const

## Task {{% param sectionnumber %}}.2: Build the application

The example source is a Java 11 application. For that we use the [openjdk-11](https://catalog.redhat.com/software/containers/ubi8/openjdk-11/5dd6a4b45a13461646f677f4) Image from Red Hat.
The example source is a Java 17 application. For that we use the [openjdk-17](https://catalog.redhat.com/software/containers/ubi9/openjdk-17/61ee7c26ed74b2ffb22b07f6) Image from Red Hat.

Create a new job inside `.gitlab-ci.yml` with the following configuration:

* job name: `build_application`
* stage: `build`
* image: `registry.access.redhat.com/ubi8/openjdk-11:latest`
* image: `registry.access.redhat.com/ubi9/openjdk-17:latest`
* script:`./gradlew assemble`

Don't forget to add the `build` stage to the stages list.
Expand All @@ -70,9 +70,9 @@ The pipeline should now look like this:
After committing the changes a new pipeline starts using the updated configuration.


Go to your GitLab project and check the pipelines under `CI/CD` --> `Pipelines`.
Go to your GitLab project and check the pipelines under `Build` --> `Pipelines`.

The Java 11 application is built using the [Gradle Build Tool](https://gradle.org/)
The Java application is built using the [Gradle Build Tool](https://gradle.org/)

Check the Gradle build log and verify whether the build succeeded or not.

Expand All @@ -81,7 +81,7 @@ Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileJava
> Task :processResources
> Task :classes
> Task :bootJarMainClassName
> Task :resolveMainClassName
> Task :bootJar
> Task :jar
> Task :assemble
Expand Down
7 changes: 4 additions & 3 deletions content/en/docs/05/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ weight: 5
sectionnumber: 5
---

In GitLab CI/CD, variables can be used to customize jobs by defining and storing values. When using variables there is no need to hard code values. In GitLab, CI/CD variables can be defined by going to `Settings` --> `CI/CD` --> `Variables` or by simply defining them in the .gitlab-ci.yml file.

![GitLab Variables](../variable.png)
In GitLab CI/CD, variables can be used to customize jobs by defining and storing values. When using variables there is no need to hard code values.
In GitLab, CI/CD variables can be defined by going to `Settings` --> `CI/CD` --> `Variables` or by simply defining them in the .gitlab-ci.yml file.

Variables are useful for configuring third-party services for different environments, such as testing, staging, production, etc. Modify the services attached to those environments by simply changing the variable that points to the API endpoint the services need to use. Also use variables to configure jobs and then make them available as environment variables within the jobs when they run.

As pointed out before, you can define variables in your `gitlab-ci.yml`. You can reuse this variable within your pipeline across different jobs and stages.

If you want to reuse a variable across different Projects or Groups, you can define them through your GitLab instance (`Settings` --> `CI/CD` --> `Variables`)

![GitLab Variables](../variable.png)

In this lab we will talk about the variables in the `gitlab-ci.yml` file only.

{{% alert color="primary" %}}
Expand Down
4 changes: 2 additions & 2 deletions content/en/docs/06/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Create a new job inside `.gitlab-ci.yml` with the following configuration:

* job name: `test_application`
* stage: `test`
* image: `registry.access.redhat.com/ubi8/openjdk-11:latest`
* image: `registry.access.redhat.com/ubi9/openjdk-17:latest`
* script:`./gradlew check`

{{% details title="test job solution" mode-switcher="normalexpertmode" %}}
Expand Down Expand Up @@ -48,7 +48,7 @@ stages:
## Task {{% param sectionnumber %}}.2: Check the pipeline
Go to your GitLab project and check the pipelines under `CI/CD` --> `Pipelines`.
Go to your GitLab project and check the pipelines under `Build` --> `Pipelines`.

Check that the test job was successful.

Expand Down
2 changes: 1 addition & 1 deletion content/en/docs/07/build_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ As mentioned in the variables Lab sensitive data, for example `DOCKER_USERNAME`

## Task {{% param sectionnumber %}}.2: Check the pipeline

Go to your GitLab project and check the pipelines under `CI/CD` --> `Pipelines`.
Go to your GitLab project and check the pipelines under `Build` --> `Pipelines`.

Check that the image build job was successful.

Expand Down
5 changes: 4 additions & 1 deletion content/en/docs/09/job_control.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Use `except` to define when a job does not run.

Use the `only:refs` and `except:refs` keywords to control when to add jobs to a pipeline based on branch names or pipeline types.

{{% alert title="Warning" color="secondary" %}}`only` and `except` are not being actively developed. To control when to add jobs to pipelines, use rules instead.
{{% /alert %}}


## {{% param sectionnumber %}}.2: Execution control

Expand All @@ -54,7 +57,7 @@ Use `allow_failure` when you want to let a job fail without impacting the rest o
* Add a new Job execution rule, the job should run only on the `release` branch
* Add a script block with a simple `echo` command

Commit and push these changes to the main branch and go to `CI/CD` --> `Pipelines` and check the pipeline status. You may notice that the job `deploy_to_prod` is not visible. This is because we add an execution rule for the `release` branch only. To fix this, we need to switch back to `Repository` --> `Branches` and create a new branch called `release`.
Commit and push these changes to the main branch and go to `Build` --> `Pipelines` and check the pipeline status. You may notice that the job `deploy_to_prod` is not visible. This is because we add an execution rule for the `release` branch only. To fix this, we need to switch back to `Repository` --> `Branches` and create a new branch called `release`.

Now the pipeline should run again and we can see the newly created job. After the pipeline executed successfully, you may notice that the `deploy` step wasn't executed yet and isn't marked with a green tick. This is because we configured the job as a manual action. To trigger this job, we need to select the job and do it manually.

Expand Down
2 changes: 1 addition & 1 deletion content/en/docs/11/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Now the pipeline should fail because the GitLab Secret Analyzer will find a priv

![security_pipeline_fail](../security_pipeline_fail.png)

Here you see the failed pipeline. By clicking on the right side you can download the job artifacts. To get the report of the failed job, click on `Download secret_detection_default_branch:secret_detection artifact`. We will learn more on artifacts in the next lab.
Here you see the failed pipeline. By clicking the download menu ⍗ on the right side you can download the job artifacts. To get the report of the failed job, click on `Download artifacts` and `secret_detection_default_branch:secret_detection`. We will learn more on artifacts in the next lab.

{{% alert title="Warning" color="secondary" %}}If you ever push a secret into a repository, **YOU MUST CONSIDER THIS SECRET AS INSECURE**. Remove the secret from the repository and change all related secrets!{{% /alert %}}

Expand Down
Binary file modified content/en/docs/11/security_pipeline_fail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion content/en/docs/12/artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Click on `Download` to get the Trivy report file and open it to see the report.

## Task {{% param sectionnumber %}}.3: Pipeline Artifacts Lab

Go to your pipeline `CI/CD` --> `Pipeline` and click on the to see the downloadable artifacts.
Go to your pipeline `Build` --> `Pipelines` and click on the download menu ⍗ to see the downloadable artifacts.

Then download them and open the JUnit test report.

Expand Down
2 changes: 1 addition & 1 deletion manifests/04.0/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble
2 changes: 1 addition & 1 deletion manifests/05.0/05.3/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble
2 changes: 1 addition & 1 deletion manifests/05.0/05.5/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble
4 changes: 2 additions & 2 deletions manifests/06.0/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
2 changes: 1 addition & 1 deletion manifests/06.0/test-job-base.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
4 changes: 2 additions & 2 deletions manifests/07.0/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/08.0/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/09.0/09.4/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/09.0/09.6/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/10.0/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/11.0/11.1/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/11.0/11.4/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/12.0/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ build_application:
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble

test_application:
stage: test
image: registry.access.redhat.com/ubi8/openjdk-11:latest
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew check
artifacts:
Expand Down

0 comments on commit bcacccf

Please sign in to comment.