Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #19232
Closed
Open
Issue created Jun 27, 2016 by Antoine Gaillard@antoine.gaillard13

Run jobs only/except when there are changes for a given path or file

Problem to Solve

There are certain scenarios in software development where you want different behavior in a single repo/CI job based on the files that were changed within that repo for the specific job run:

  1. Monorepos where multiple builds are stored in a single repository
  2. Statically rendered content where only the changed content needs to be regenerated
  3. You only want to execute part of the pipeline if the Dockerfile has changed

Proposal

We will add a new changes element to only/except which will allow you to specify globs of files in the repo where, only or except in cases where files in that glob were added, modified, or deleted.

  only:
    changes:
      - Dockerfile
      - assets/*

Behavior in "New Branch" case

The situation of a new branch is unique when comparing only/except changes since it's unclear in the product (for now) what to compare against. We decided that perhaps the most reasonable solution is to treat the new branch push as a separate event, and therefore to evaluate changes as true for all files; what this means is that for the first pipeline of a new branch, everything will be built.

This behavior will be OK for some teams, but others will want behavior that is more aware of the target branch this will eventually be merged to, and to evaluate the changes in the branch against that target. We may eventually build that capability into the product, but for now this feature will be most valuable on relatively stable branches (master for sure, but also other longer-lived branches.)

Edited Sep 17, 2018 by Jason Yavorska
Assignee
Assign to
Time tracking