On Tuesday, 11 August 2020 at 15:55:17 UTC+2 Gianluca wrote:

> Hi,
> yes ... we do.
>
> We have various Jenkinsfile in sub-directories and different pipelines.
>
> This is how we did it:
> - we have one Multibranch project for each Jenkinsfile and in the 
> configuration we specify which Jenkinsfile is used for the jobs
> - we have a custom check that we use on the "when" block to avoid that a 
> pipeline is been built when a push only affects other directories
>
> // There is a bug in the changeset Jenkins command: 
> https://issues.jenkins-ci.org/browse/JENKINS-44849
> // ---
> // It returns true if the list of changed files in the PR matches the grep 
> pattern passed
> // NOTE: it will always returns true in case the build is running on a branch 
> and not on a PR
> // because we always want to run a full pipelines on master, release and 
> feature branches
> def areFilesChanged(grepPattern) {
>     if (!env.CHANGE_TARGET) return true
>     sh(
>         // NOTE: the triple-dot are necessary to get the same diff result 
> shown by GitHub PRs
>         script: "git diff origin/${env.CHANGE_TARGET}...HEAD --name-only | 
> grep '${grepPattern}'",
>         returnStatus: true
>     ) == 0
> }
>
>
> and that's it.
>

I see, is this function called within the Jenkinsfile itself, right?
Is your build starting to run, then you are calling that function and the 
build is interrupted prematurely if the files modified doesn't match your 
pattern? 


On Tuesday, 11 August 2020 14:46:40 UTC+1, Jonathan Ballet wrote:
>>
>>
>> Hello,
>>
>> In one of our Git repository, we have a directory hierarchy similar to 
>> this:
>>
>>     dev/
>>         Jenkinsfile
>>         folder-1/Jenkinsfile
>>         folder-2/Jenkinsfile
>>
>>     test/
>>         Jenkinsfile
>>         folder-3/Jenkinsfile
>>         folder-4/Jenkinsfile
>>
>> There are other files as well, in each sub-directories.
>>
>> I'm looking for a way to have 6 builds out of this repository:
>>
>> * 1 build runs `dev/Jenkinsfile` when any file changes in the `dev/` 
>> directory and children
>> * 1 build runs `dev/folder-1/Jenkinsfile` when any file changes in the 
>> `dev/folder-1/` directory
>> * 1 build runs `dev/folder-2/Jenkinsfile` when any file changes in the 
>> `dev/folder-2/` directory
>> * etc.
>>
>> Also, I'd like to have these builds scopped by branches, we are using the
>> Multibranch Pipeline (+ GitHub Branches Source) build type for that.
>>
>> Is there a known solution that combines all the above? (sub-directories, 
>> pipelines, webhooks triggered by Git(Hub) with branches support)
>>
>> Thanks!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/1dbab58e-18cf-4369-96a2-549b4e919c47n%40googlegroups.com.

Reply via email to