#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 basic CI/CD application
-
In a new browser window navigate to this url: https://gitlab.com/gitlab-learn-labs/sample-projects/cicd-workshop/workshop-project.
-
Next click Fork in the top right of the screen.
-
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. DO NOT change the name of the project as this will break some automation later on in the workshop. Next click Fork project.
-
Wait a few minutes then you should be brought to forked project in your recently created group.
-
You should now be on your workshop-project project homescreen. 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.
-
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
-
First click Workshop Project in the top left of the screen. Now that we have our project imported, go ahead and take a look at the .gitlab-ci.yml file.
-
Notice that we have a simple pipeline already defined. We have two stages, build & test, as well as an build_app job that uses the before_script & script keywords.
-
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 dropdown next to Open in Web IDE. 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 mocha mocha-simple-html-reporter mocha-junit-reporter chai-http 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!"
-
Once you have added the code you can click Commit changes which should immediately trigger the pipeline to build no issues were detected in the .yml file. For troubleshooting use the Validate tab to see where your pipeline is broken.
-
To view the job use the left hand navigation menu to click CI/CD -> 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 CI/CD -> Pipelines, click Run pipeline, select simple-pipeline and click Run pipeline once again.
From here you can watch your pipeline run.
- 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