Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63837

github push trigger only on changes paths

    XMLWordPrintable

Details

    Description

      It would be nice to add an option to the github plugin's webhook triggers to only trigger the scm polling iff there are changes in certain file paths.

      Currently the workaround is to create a job that triggers using a webhook, and there figure out what files that have changed in using changesets, and then build the relevant job.

       

      Generic webhook triggers seem interesting alternative, however, I've been unable to get them to work with multibranch pipelines.

      Attachments

        Activity

          aitorpazos Aitor Pazos added a comment -

          We find that `github-branch-plugin` in combination with multibranch build strategies doesn't work as expected.

          We tried to use this to support monorepos through JobDSL with no luck (ommiting some additional config):

          multibranchPipelineJob("${args.jobName}") {
            description("Multibranch job automatically maintained by monorepo pipeline")
            branchSources{
              github {
                [...]
          
                // Setting included and excluded branches
                includes("*")
                excludes("dependabot/*")
              }
            }
           
            factory {
              workflowBranchProjectFactory {
                scriptPath("${args.project}/Jenkinsfile")
              }
            }
           
            configure {
              [...] 
              
              // Start configuring build strategies
              def buildStrategies = it / sources / data / 'jenkins.branch.BranchSource' / buildStrategies
           
              // Configures which file changes are considered to trigger and ignore builds
              buildStrategies << 'com.igalg.jenkins.plugins.multibranch.buildstrategy.IncludeRegionBranchBuildStrategy' {
                includedRegions("${args.project}/**") 
              }
              buildStrategies << 'com.igalg.jenkins.plugins.multibranch.buildstrategy.ExcludeByIgnoreFileBranchBuildStrategy' {
                ignorefilePath("${args.project}/.jenkinsignore")
              }
            }
          }

          The buildStrategies are ignored and all projects in the monorepos get their build triggered no matter if they have changes within their directory or not.

           

          aitorpazos Aitor Pazos added a comment - We find that `github-branch-plugin` in combination with multibranch build strategies doesn't work as expected. We tried to use this to support monorepos through JobDSL with no luck (ommiting some additional config): multibranchPipelineJob( "${args.jobName}" ) { description( "Multibranch job automatically maintained by monorepo pipeline" ) branchSources{ github { [...] // Setting included and excluded branches includes( "*" ) excludes( "dependabot/*" ) } } factory { workflowBranchProjectFactory { scriptPath( "${args.project}/Jenkinsfile" ) } } configure { [...] // Start configuring build strategies def buildStrategies = it / sources / data / 'jenkins.branch.BranchSource' / buildStrategies // Configures which file changes are considered to trigger and ignore builds buildStrategies << 'com.igalg.jenkins.plugins.multibranch.buildstrategy.IncludeRegionBranchBuildStrategy' { includedRegions( "${args.project}/**" ) } buildStrategies << 'com.igalg.jenkins.plugins.multibranch.buildstrategy.ExcludeByIgnoreFileBranchBuildStrategy' { ignorefilePath( "${args.project}/.jenkinsignore" ) } } } The buildStrategies are ignored and all projects in the monorepos get their build triggered no matter if they have changes within their directory or not.  

          People

            bitwiseman Liam Newman
            thehosh Hosh
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: