Skip to content
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

[JENKINS-75102] Fix Windows Docker running Windows container with spaces in workspace path #326

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

MarkRx
Copy link
Contributor

@MarkRx MarkRx commented Jan 9, 2025

Fixed docker windows not working when a running windows containers when the workspace path has both a space and a '@'.

The consecutive double quote escape strategy used by the durable-task-plugin does not work in all cases when passed in to docker exec. Launching the command in the container with call like done here does. Unfortunately changing the durable-task-plugin to use call broke other non-docker use cases and I couldn't find a strategy that handled every case. Additionally, changing the jenkins-wrapper.bat launch command is riskier. I thus opted to handle this case in the logic around decorating the launcher command in the docker-workflow-plugin.

See JENKINS-75102 for more details.

Testing done

A unit test has been created that covers this case. It uses Assume to only run if on Windows, docker is installed, and docker is setup to run Windows containers. The current build process may not be able to run it at this time but it does work locally.

I also tested on a live instance Windows agent running docker using a multibranch pipeline job with branches "main" and "feature/foobar" the later of which tests the '%' character.

pipeline {
    agent {
        label 'docker_windows1809'
    }

    stages {
        stage('Stage') {
            steps {
                ws("C:/jenkins/multi space space") {
                    script {
                        docker.image('microsoft-images-docker.registry.paychex.com/windows/servercore:ltsc2019').inside {
                            bat "echo %cd%"
                        }
                    }
                }
            }
        }
    }
}

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@basil basil added the bug label Jan 20, 2025
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@basil basil merged commit 1001d94 into jenkinsci:master Jan 20, 2025
3 of 4 checks passed
@basil basil changed the title JENKINS-75102 Fix Windows docker running Windows container with spaces in workspace path [JENKINS-75102] Fix Windows Docker running Windows container with spaces in workspace path Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants