[FIXED JENKINS-73075] Clarify documentation of the environment variable P4_CHANGELIST #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Summary
Clarifies the behavior of the plugin when a workspace points to an unpopulated depot.
Problem
P4_CHANGELIST is set to the latest p4 changelist number across the Perforce server when the list of changelists is empty. This behavior is commented and can be inferred from the code:
However, this edge case is not explicitly documented for P4_CHANGELIST at its description:
The documentation is currently silent about when the workspace is not populated.
Impact
It is likely that the users assume that P4_CHANGELIST always contains a submitted change list number if no error is raised and it is not null. It is likely to be used as a unique identifier of the code version in many places in CI/CD systems.
The latest change list, that may even end up being deleted without any submission, can propagate through the Jenkins systems and hurt the integrity or consistency of builds and their artifacts and logs.
An explicit documentation may also help the users with understanding the content of P4_CHANGELIST when a workspace is not populated.
Example
If a workspace points to a non-existing depot and the user code uses Jenkins's checkout task with Perforce SCM, P4_CHANGELIST will contain the latest change list number in the Perforce server.
Recommended Solution
Change the documentation as follows:
Testing done
This is echoing what is already documented in code documents. It's a more specific documentation so I didn't include any tests for the existing behavior.
There are no changes in the code so the behavior will remain the same. However, the author has experienced this behavior.
-->
Submitter checklist
Link to relevant pull requests, esp. upstream and downstream changes[N/A]Ensure you have provided tests - that demonstrates feature works or fixes the issue[N/A]