This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch ci/skip-staging-build-when-no-site-changes in repository https://gitbox.apache.org/repos/asf/struts-site.git
commit 916aab59d68cc79490e41b78ae6085212c2c2e02 Author: Lukasz Lenart <[email protected]> AuthorDate: Wed Jul 1 09:53:13 2026 +0200 ci: skip staging site build when a PR changes no site files The Struts-site multibranch job rebuilt Jekyll and pushed to asf-staging on every PR, even PRs that touch only CI/docs and leave source/ untouched, producing an identical staged site. Add a 'Check for site changes' stage that diffs a PR against its target branch and sets SITE_CHANGED; gate the build, deploy, and PR-comment stages on it. Branch builds (main) always rebuild. Skipped stages still report success, so any required check stays green. Co-Authored-By: Claude Opus 4.8 <[email protected]> --- Jenkinsfile | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ee06965dd..1e0e244e1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,31 @@ pipeline { PATH="${GEM_HOME}/bin:${RUBY_PATH}/bin:${env.PATH}" } stages { + stage('Check for site changes') { + steps { + script { + if (env.CHANGE_TARGET) { + // PR build: only rebuild when files that affect the generated site changed. + sh "git fetch --no-tags origin +refs/heads/${env.CHANGE_TARGET}:refs/remotes/origin/${env.CHANGE_TARGET}" + def files = sh( + script: "git diff --name-only origin/${env.CHANGE_TARGET}...HEAD", + returnStdout: true).trim() + echo "Files changed in this PR:\n${files}" + env.SITE_CHANGED = files.readLines().any { + it ==~ /^(source\/.*|_config\.yml|Gemfile(\.lock)?)$/ + } ? 'true' : 'false' + } else { + // Branch build (e.g. main): always rebuild. + env.SITE_CHANGED = 'true' + } + echo "SITE_CHANGED=${env.SITE_CHANGED}" + } + } + } stage('Build a staged website') { + when { + expression { env.SITE_CHANGED == 'true' } + } steps { sh ''' echo Generating a new version of website @@ -29,6 +53,9 @@ pipeline { } } stage('Deploy to stage area') { + when { + expression { env.SITE_CHANGED == 'true' } + } steps { sh ''' echo "Pushing changes into stage site" @@ -55,7 +82,10 @@ pipeline { } stage('Comment on PR') { when { - changeRequest() + allOf { + changeRequest() + expression { env.SITE_CHANGED == 'true' } + } } steps { script {
