Trigger CI Pipeline
CI/CD

Trigger CI Pipeline

We are now going to setup a branch called stage and commit our GitLab job control file.

Step 1 - Commit code to local stage branch

Make sure you are in the root directory of the project folder


cd ~/workspace/ndfclab/ansible


Step 2 - Create and Checkout a Local Branch Called stage


git checkout -b stage


Step 3 - Double Check Local stage Branch Changes

First issue the git status . command to see the list of files that have been modified in the previous lab tasks.


git status .

    On branch stage
    Untracked files:
      (use "git add ..." to include in what will be committed)
            .gitlab-ci.yml
            leaf_devices.prod.yml
            leaf_devices.stage.yml
            verify_fabric.yml

    nothing added to commit but untracked files present (use "git add" to track)

Check Closely!

Make sure your modified list of files matches the list of files above in the lab guide. If it does not then that means you missed a step or did not save one of the files you modified.

Step 4 - Add New Gitlab Job Control File and Verify Playbook For Commit


git add .


Step 5 - Commit Code

Now commit the code to your github repo stage branch.


git commit -m "PipeLine Changes"

    [stage e6e69b3] PipeLine Changes
    4 files changed, 158 insertions(+)
    create mode 100644 .gitlab-ci.yml
    create mode 100644 leaf_devices.prod.yml
    create mode 100644 leaf_devices.stage.yml
    create mode 100644 verify_fabric.yml

Step 6 - Push Local Branch stage to Remote


git push --set-upstream origin stage 

    Enumerating objects: 5, done.
    Counting objects: 100% (5/5), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (4/4), 1.11 KiB | 1.11 MiB/s, done.
    Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
    remote: 
    remote: To create a merge request for stage, visit:
    remote:   http://10.0.208.215/CL-POD27/LTRDCN-3439/-/merge_requests/new?merge_request%5Bsource_branch%5D=stage
    remote: 
    To 10.0.208.215:CL-POD27/LTRDCN-3439.git
     * [new branch]      stage -> stage
    branch 'stage' set up to track 'origin/stage'.

Step 7 - Check the Code on Gitlab

Return to GitLab in your browser. In the branch drop-down, select your stage branch:

  1. Click main
  2. Click stage branch

Step 8 - Check to Ensure the Lint Stage was Run

As soon as the code was committed to the stage branch, Ansible Lint validation was triggered, open pipelines:

  1. Click Build on the side menu
  2. Then click Pipelines



  3. Only the lint stage is triggered when committing the code to the stage branch, circle check icon indicates pipeline succeeds. To see details of the job click Passed under the Status column:



    This shows the ansible_lint job ran successfully for the initial setup commit.



    If you want to see detailed logs of the job run you can click the ansible lint job.



Step 9 - Create a Merge Request (Also known as a Pull Request)

Now we need to create merge request to verify/test the configuration against the NDFC staging environment fabric.

  1. Click Merge requests on the side menu
  2. Then click New merge request




  3. Select stage as Source branch
  4. Select main as Target branch
  5. Then click Compare branches and continue




  6. Leave all of the fields with the default settings, then click Create merge request




  7. Click the circle icon in screen below to navigate to pipeline page




  8. Wait until the pipeline finishes, if any pipeline fails, you can click the step to check the error message

This step will take around 4-5 mins to complete

This deploy_on_stage and verify_on_stage are doing the following:

  • The deploy_on_stage runs the build_fabric.yml script against the staging fabric. This is important so that any time you make an update and commit the code in the staging branch changes will be applied against the staging fabric first.
  • The verify_on_stage runs the verify_fabric.yml and verify_dataplane.yml scripts to verify that changes pushed by the deploy on stage step did not break anything