#1 Simple Pipeline

👋 Introduction

This Challenge will walk through the steps of importing your CI/CD pipeline project and creating a basic pipeline

Step 01 - Importing a basic CI/CD application

  1. In a new browser window navigate to this url: https://gitlab.com/gitlab-learn-labs/onboarding-cohort-projects/CICD-in-GitLab.

  2. Next click Fork in the top right of the screen.

  3. Then on the fork project screen in the Project URL section we want to select our existing Learn Labs group we just created through using the redemption code. Change the name of the project to Workshop Project. Next click Fork project.

  4. Wait a few minutes then you should be brought to forked project in your recently created group.

  5. You should now be on your workshop-project project home screen. We dont want to keep the fork relationship so go ahead and use the left hand navigation menu to click through Settings -> General. Once on the settings page scroll to the bottom and click Expand next to Advanced.

  6. Scroll down again and find the Remove fork relationship section and click Remove fork relationship. Enter the project name in the input, then click confirm. Next we will want to click the name of our project in the top left.

Step 02 - creating a simple pipeline

  1. First click Project Overview(Workshop Project) from the side bar (you may need to expand it from the top left corner of the screen). Now that we have our project imported, go ahead and take a look at the .gitlab-ci.yml file.

  2. Notice that we have a simple pipeline already defined. We have two stages, build & test, as well as a build_app job that uses the before_script & script keywords.

  3. In the unit_test job we want to use the after_script keyword to echo out that the build has completed. First to edit the pipeline we need to select Edit in pipeline editor in the blue Edit dropdown. Once there lets go ahead and add an after_script to the unit_test job:

    after_script:
        - echo "build_app job has run!"

    Your new unit_test job should look like this:

    unit_test:
      stage: test
      before_script:
        - yarn add chai@4.3.7 mocha mocha-simple-html-reporter mocha-junit-reporter chai-http@4.3.0 mocha-test-url
      script:
        - ./node_modules/mocha/bin/_mocha "test/*.js" --reporter mocha-junit-reporter --reporter-options mochaFile=./testresults/test-results.xml
        - ./node_modules/mocha/bin/_mocha "test/*.js" --reporter mocha-simple-html-reporter --reporter-options output=./testresults/test-results.html
      after_script:
        - echo "build_app job has run!"
  4. Once you have added the code you can click Commit changes which should immediately trigger the pipeline to build without issues. For troubleshooting use the Validate tab to see where your pipeline is broken.

  5. To view the job use the left hand navigation menu to click Build -> Pipelines and click the hyperlink of the most recently ran pipeline.

Example: #577244133.

If you run into any issues you can use the left hand navigation menu to click through Build -> Pipelines, click Run pipeline, select simple-pipeline and click Run pipeline once again.

From here you can watch your pipeline run.

  1. Feel free to click into the unit_test job so see the output and look for the messages that we echoed out.

Check out relevant docs for jobs here

Edited by Rasheed Babatunde