I am noticing an odd issue where our P4_CHANGELIST number is populated per the last set of changes to the Jenkinfs file, but not for any 'p4sync' calls in the Jenkinsfile itself.
As an example, here's the initial Jenkinsfile sync snippet, notice the changelist "961423". From here on out, the P4_CHANGELIST variable will have that as it's changelist number.
[... snip ...] P4 Task: reverting all pending and shelved revisions. ... p4 revert /home/jenkins/jobs/build-tip/workspace%40script/... + ... rm [abandoned files] duration: (106ms) ... p4 sync /home/jenkins/jobs/build-tip/workspace%40script/...#none + ... rm -rf /home/jenkins/jobs/build-tip/workspace%40script P4 Task: syncing files at change: 961423 ... p4 sync -p /home/jenkins/jobs/build-tip/workspace%40script/...@961423 + duration: (158ms) P4 Task: saving built changes. Found last change 961423 on syncID jenkins-build-tip ... p4 client -o jenkins-build-tip + ... p4 info + ... p4 client -o jenkins-build-tip + ... p4 info + ... done [... snip ...]
A little farther in my build, I have my actual repo mappings. Here's the sync log from it:
[... snip ...] P4 Task: reverting all pending and shelved revisions. ... p4 revert /home/jenkins/workspace/build-tip/... + ... rm [abandoned files] duration: (160ms) ... p4 sync /home/jenkins/workspace/build-tip/...#none + ... rm -rf /home/jenkins/workspace/build-tip P4 Task: syncing files at change: 968942 ... p4 sync -p /home/jenkins/workspace/build-tip/...@968942 + duration: 9m 8s P4 Task: saving built changes. Found last change 968924 on syncID jenkins-build-01 ... p4 client -o jenkins-build-01 + ... p4 info + ... p4 changes //jenkins-build-01/...@968924,968942 + ... p4 changes -l -m1 @968942 + ... p4 user -o user1 + ... p4 describe -s 968942 + ... p4 fixes -c968942 + ... p4 changes -l -m1 @968936 + ... p4 user -o user2 + ... p4 describe -s 968936 + ... p4 fixes -c968936 + ... done [... snip ...]
In the case above, I would expect P4_CHANGELIST to be 968942, as it is the newest changelist for the repo at that point in the Jenkinsfile. If I were to have a workflow step right after my p4sync call that did something like this:
sh "echo ${env.P4_CHANGELIST}"
I would want the output to be '968942', but right now, it outputs '961423'.
p4paul, I think this issue may have been related to your suggestion from https://issues.jenkins-ci.org/browse/JENKINS-35314?focusedCommentId=265033&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-265033.
I reverted the top-level project definition to using the ... wildcard for mapping the workspace to look like this:
//depot/project1/tip... //client_workspace_project1/...
Using the 'Jenkinsfile' style also had the unintended consequence of the changelist info for each build not being populated (my guess was because we were effectively masking off inspecting the rest of the repo for any changes that could trigger a build). Builds were also triggered sometimes with (seemingly) no changes as well as a result. Changed it back to the example above, and things seem to be going quite a bit better now.