Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jenkins included regions not work even choose force polling using workspace

Tags:

git

  • git 1.5.4
  • jenkins 1.563
  • git plugin 2.2.1

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.

like image 951
Venus Avatar asked Nov 10 '22 06:11

Venus


1 Answers

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}}
like image 86
yegeniy Avatar answered Nov 15 '22 05:11

yegeniy