I'm trying to understand why the construct below doesnt work as I expect it
to, but have spent hours over it without success.

We use git with many branches, and a multi-branch pipeline in Jenkins to
build and test. The total build takes more than an hour, where 90% is
integration tests ((see build stage below). When several git push events
occur within a few minutes, I want a LIFO queue for the integration tests
and I also want to abort any older builds waiting to run the integration
tests.

I believe that the pipeline code below should do that by lock()'ing per
branch. However I'm seeing that when 2 builds are waiting for the lock
while an earlier build is running the integration tests, then when that
earlier build releases the lock, both of the other two builds can acquire
the lock simultaneously and start running integration tests.

The lockable resources "integrationTests-<branchName>" get created
dynamically, in case that plays any role.

Anything I'm missing in my line of thoughts?

We run on Jenkins 2.37, with latest version of all pipeline plugins.


// ... other stages to build, static code analysis, unit tests etc

stage('Integration testing') {
    milestone(label: 'IntegrationTests-AttemptingToStart')
    String lockResource = "integrationTests-${env.BRANCH_NAME}"
    lock(resource: lockResource, inversePrecedence: true) {
        try {
            integrationTestsStage()
        } finally {
            echo "Done with all integration tests."
            milestone(label:'IntegrationTests-Done') // abort all older
builds (for same git branch) that haven't passed this milestone yet
        }
    }
}

Anyone any input or helping thoughts? Thanks,
 stefan.

-- 
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/CABwQARtAMHKARDafR6LbHiPGnAOx8ARX1on41PwgBqUNaW%2BhwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to