The only way I found to achieve that it's using "when" expression of 
"stage" with a function I've built to check if thing changed.

when {
expression {
    FSTChangePatterns.any{pattern -> sideCars.areFilesChanged(pattern)}
}
}

Where the areFilesChanged is:

// 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
}

Cheers,
Gianluca.

Il giorno martedì 8 settembre 2020 alle 10:01:21 UTC+1 yogesh...@gmail.com 
ha scritto:

> Hi All,
>
> I am using webhook to trigger my declarative pipeline job.
> I  want to ignore the directory in my github project, whenever there is 
> changes/commits to particular directory it should not trigger the build. 
> Apart from that directory it should trigger the build.
> Is there any way we can achieve this in jenkins pipeline?
>
>
> Regards,
> Yogesh Bidari

-- 
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/4d0c3e1b-63fe-4e33-9a34-a6c6adaa1090n%40googlegroups.com.

Reply via email to