my git project is like so:
testproject/code/b2b/admin/...
testproject/code/b2b/app/...
testproject/code/b2c/admin/...
testproject/code/b2c/app/...
in Additional Behaviours section, I add Force polling using workspace. and also add Polling ignores commits in certain paths.
in Included Regions,I wrote
code/b2b/admin/.*
code/b2c/admin/.*
In build trigger section,I wrote * * * * *
in Poll SCM but, no matter where I changed the code in testproject, it doesn't trigger.
That polling plugin does indeed seem to be broken, but as a Jenkins 1.x workaround you can use a downstream job, that's kicked off with a conditional step, which leverages the git whatchanged
command.
git whatchanged "${GIT_PREVIOUS_SUCCESSFUL_COMMIT}".."${GIT_COMMIT}" | grep '^:' | cut -f 2 | grep '^{path}/'
Here's a more readily useful snippet leveraging the whatchanged
from a bit of Jenkins Job Builder code.
builders:
- conditional-step:
on-evaluation-failure: dont-run
condition-kind: or
condition-operands:
- condition-kind: shell
condition-command: |
if [[ -z "${{GIT_PREVIOUS_SUCCESSFUL_COMMIT}}" ]]; then
echo 'GIT_PREVIOUS_SUCCESSFUL_COMMIT was empty'
elif [[ "${{GIT_PREVIOUS_SUCCESSFUL_COMMIT}}" != "${{GIT_COMMIT}}" ]]; then
git whatchanged "${{GIT_PREVIOUS_SUCCESSFUL_COMMIT}}".."${{GIT_COMMIT}}" | grep '^:' | cut -f 2 | grep '^{path}/'
else
# This should have been selected earlier as the build-cause operand of the conditional step...
echo 'previous and current commits match, implying the job is kicked off manually'
fi
steps:
- trigger-builds:
- project: 'downstream job'
condition: SUCCESS
block: true
predefined-parameters: |
GITREF=${{GIT_COMMIT}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With