Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-16560

Trigger pipeline only if certain files are changed

    XMLWordPrintable

Details

    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

    Description

      So I posted this on the Community Discussion site, but it's worth having here.

      We need to restrict our pipeline steps to only run when commits contain changes in our client/*/ filepath glob.

      Concourse.ci, Drone.ci, and I assume other CI servers provide the option to restrict steps to commits only containing certain file paths.

      At the moment it seems we are limited to manually grepping "git log" and emitting an exit 1, which would cause the build to fail.

      Ideally I'd want a branch build to not even start, so being able to specify branches and steps to only run when there are (or are not) matching files in the commit would look like:

      Unable to find source-code formatter for language: yml. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      - step:
        image: node:alpine-8
        script:
          - npm install
          - npm run prod
        filter:
          includes:
            - client/src/**/*
            - package.json
         
      ...
      

      So that commits containing file changes matching:

      • server/*/ and client/*/ would run the above step
      • server/*/ would not run the above step
      • client/*/ would run the above step
      • package.json would run the above step

      Other examples:

      - step:
        filter:
          excludes:
            - server/**/*.cshtml
      
      - step:
        filter:
          includes:
            - client/build/gulp/**/*
          excludes:
            - server/**/*.cshtml
      

      excludes would prevent the step from running if any files in the commit match the patterns.

      includes would ensure that the step only ran if at least one of the changed files matches the patterns.

      Attachments

        Issue Links

          Activity

            People

              mkleint mkleint (Inactive)
              zeno.jiricek ZenobiusJ
              Votes:
              158 Vote for this issue
              Watchers:
              134 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: