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/nac


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
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   requirements.yml

    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            .gitlab-ci.yml
            test.yml
            validate.yml

    no changes added to commit (use "git add" and/or "git commit -a")

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 "Add PipeLine"


    [stage e477eeb] Add PipeLine
    4 files changed, 264 insertions(+)
    create mode 100644 .gitlab-ci.yml
    create mode 100644 test.yml
    create mode 100644 validate.yml

Step 6 - Push Local Branch stage to Remote


git push --set-upstream origin stage 


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

Step 7 - Check the Code on Gitlab

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

  1. Navigate back to repo by clicking Code
  2. Then click Repository




  3. Click main
  4. Click stage branch




  5. Review stage branch commits





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, the green circle with a check icon indicates the pipeline succeeded. 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.



    If you want to see detailed logs of the NAC Validate job that was ran, you can click the nac_validate job on the right hand side under Related jobs.



    To see the detailed logs of the last yamllint job that was ran you can click the yamllint job on the right hand side under Related jobs.




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 blue circle with a half moon icon next to Merge request pipeline 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




  9. While the pipeline is running, you can click on Job dependencies then click on the Show dependencies slider to see which jobs must be executed before the next jobs can be ran




  10. The pipeline should complete and all jobs should have passed denoted by the green circle with a check icon


This step will take around 7-8 mins to complete

The deploy_stage and test_stage are doing the following:

  • The deploy_stage runs the vxlan.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 test_stage runs the vxlan.yml scripts to verify that changes pushed by the deploy on stage step did not break anything