-
-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use core.autocrlf true for Windows line termination #899
Use core.autocrlf true for Windows line termination #899
Conversation
Windows virtual machines are currently configured to not use LF as their git end of line. That causes failures when spotless formats files on Windows that were originally created with Unix (LF) line termination. This is a workaround until we update the Windows virtual machine definition to fix: * jenkins-infra/helpdesk#3865
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned elsewhere, this PR should go along #898 as
plugins that use spotless will fail their builds on a Windows VM when they pass on a Windows container. Switch from container to VM makes that issue visible to more people.
Related:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Mark!
@lemeurherveCB suggested a technique that I can use to test this before it is merged. I'll do that testing before I merge it. |
CC @jtnord |
vars/infra.groovy
Outdated
@@ -142,6 +142,8 @@ Object checkoutSCM(String repo = null) { | |||
// Enable long paths to avoid problems with tests on Windows agents | |||
if (!isUnix()) { | |||
bat 'git config --global core.longpaths true' | |||
// TODO: Remove when https://github.com/jenkins-infra/helpdesk/issues/3865 is resolved | |||
bat 'git config --global core.eol lf' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the spotless issue is that it ends up just guessing that the line ending is native becasue there is no configuration otherwise.
The alternative (which uses windows line ends on windows, so is more like what windows would do) is to set git config --global core.autocrlf true
this should cause the files to have line ends changed on windows, and will be picked up by spotless to go "oh it is converting line ends, and I am on windows" so spotless does not end up guessing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very, very much! Your guidance was exactly what I needed. I confirmed that core.autocrlf true
resolves the spotless formatting issue and allows builds to be portable between ci.jenkins.io Windows containers and Windows virtual machines Setting core.eol lf
does not resolve the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For info: jenkins-infra/packer-images#1649
Use LF as git end of line terminator on Windows
Windows virtual machines are currently configured to not use LF as their git end of line. That causes failures when spotless formats files on Windows that were originally created with Unix (LF) line termination.
This is a workaround until we update the Windows virtual machine definition to fix:
Testing done
I added the following text to the start of each Jenkinsfile in the test jobs and confirmed that job output contained the expected git commands on Windows agents and the test jobs passed with both
useContainerAgent: true
anduseContainerAgent: false
.Plugins that were tested with both settings include:
Plugins that were tested with only one setting (because they require a virtual machine to run their container based tests):