-
Bug
-
Resolution: Unresolved
-
Major
-
None
Hi, team,
When we use the ‘Sparse Checkout paths’ of Additional Behaviours, we meet one question.
Environment Descriptions:
Jenkins running type: Docker
Jenkins Job type: Pipeline
Sparse Checkout Path: test
Script Path: test/Jenkinsfile
Question Descriptions:
Under test/, we had two files, one is Jenkinsfile, the other one is one shell script which will be called by Jenkinsfile.
After configuring the git source, and specified the Sparse checkout paths by adding an additional behaviour and Script Path as above,
the first build can be run successfully.
And then, we change the Code Structure to Git server side.
Moved Jenkinsfile and Shell script to test/test1/.
And indisde Jenkins job, changed Sparse Checkout path from test to test/test1, changed Script Path from test/Jenkinsfile to test/test1/Jenkinsfile.
And executed the second build, Console output of Jenkins threw one error:
stderr: error: Entry ‘test/Jenkinsfile’ not uptodate. Cannot update sparse checkout.
After investigation, we found that the Jenkins workspace haven’t be updated to the new code structure, still the old one.
If we clean the workspace manually, the build can be run successfully.
How to implement this in Jenkins automatically?
Please help to investigate this issue.
Thanks in advance.
The git plugin does not apply changes to the sparse checkout definition to the workspace.
A workaround in Pipeline is to use deleteDir() in the Jenkinsfile when making this type of structural change. The workspace will be removed by the call to deleteDir() and then the currently defined sparse checkout will be applied to the fresh checkout.