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

Escape environment variables before pass it to docker run #215

Closed
wants to merge 4 commits into from

Conversation

AlexPykavy
Copy link

@AlexPykavy AlexPykavy commented May 28, 2020

In order to avoid issues with spaces.

We've used Bitbucket Branch Source Jenkins plugin which automatically adds environment variables like CHANGE_TITLE. In our case, PR title contains spaces which leads to error like:
Error: docker: invalid reference format: repository name must be lowercase.

We assume that issue is because of spaces in the variable but can be wrong, please share your thoughts on this point.

@lee-at-work
Copy link

This PR should be reviewed and be accepted if the fix is correct. Because when PR title has quotes in them, it jams up our build insider docker runs. Since it only happens from time to time, we always spend hours before realizing that PR titles have quotes.

To correctly pass it as `docker run` argument.

NOTE: WindowsUtil is used because the logic seems to be the same for Linux.
To check that they are correctly escaped.
Alex Pykavy added 2 commits February 27, 2021 21:32
Because new tests requires docker daemon for the correct work.

A 'docker' label was taken from the list of supported platforms:
https://github.com/jenkins-infra/documentation/blob/master/ci.adoc
To check that environment variables with spaces are escaped before passing them to container.
@AlexPykavy
Copy link
Author

I've tried to complete the PR using #220 as a base and cover logic with tests but encountered an issue. According to the default configuration, CI build is run on 'linux' platform that doesn't have any Docker daemon installed.

Maybe I'm doing something wrong when implementing such tests but don't see any other option to check this logic. If you have better ideas, please share them 😀

@AlexPykavy
Copy link
Author

Also, I've tried to extend the list of target platform with 'docker' (found this in the https://github.com/jenkins-infra/documentation/blob/master/ci.adoc) but seems like it's impossible to override this configuration from PR and it's pulled from the origin repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants