Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • hello-world-template hello-world-template
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ci-cd-discovery
  • templates
  • hello-world-templatehello-world-template
  • Issues
  • #8

Closed
Open
Created Nov 30, 2020 by Philippe Charrière@pcharriereOwner0 of 11 tasks completed0/11 tasks

08-rules

You may probably control if a job is executed when pushing on the master branch, or when updating a merge request. For this, you can use rules.

TODO

  • create a merge request from this issue
  • open the WebIDE
  • update the .gitlab-ci.yml file
  • add a new stage: all_under_control
  • add a new job: when_master belonging to all_under_control
    when_master:
      stage: all_under_control
      tags: [docker]
      rules:
        - if: $CI_COMMIT_BRANCH == "master" # 1️⃣
      script: |
        echo "We are on the master branch"

    1️⃣ we test if we are pushing on the master branch, and if yes, the job will be triggered

  • add a new job: when_merge_request belonging to all_under_control
    when_merge_request:
      stage: all_under_control
      tags: [docker]
      rules:
        - if: $CI_MERGE_REQUEST_IID # 1️⃣
      script: |
        echo "We are on the branch $CI_COMMIT_REF_NAME"
        echo "IID: $CI_MERGE_REQUEST_IID"

    1️⃣ we test if we are doing a merge request, and if yes, the job will be triggered

  • commit your changes, it will trigger the pipeline
  • observe the pipeline (how many jobs in the all_under_control stage ?)
  • observe the output of the pipeline
  • merge on master (the pipe will be triggered again)
  • observe the pipeline (and output) again
Edited Dec 02, 2020 by Philippe Charrière
Assignee
Assign to
Time tracking