Skip to content

Powershell shell assumes it is ran on Windows

Summary

Summarize the bug encountered concisely

Powershell is now cross platform (Windows, OSX, Linux) and is great scripting tool. We shouldn't assume that it only runs on Windows with things like .ToBackslash(): https://gitlab.com/gitlab-org/gitlab-runner/blob/master/shells/powershell.go#L93

Steps to reproduce

Run any build with powershell shell on OSX or Windows. Paths are generated with , not /.

Expected behavior

Paths should use /, because powershell supports slash delimited paths:

PS C:\work> ls c:/work/build.status


    Directory: C:\work


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2017-02-16     12:13           3997 build.status

Relevant logs and/or screenshots

Excerpt from generated powershell script.

md "\Users\gitlab\builds\6d255f49\0\games\funkidracing.tmp" -Force | out-null
Set-Content "\Users\gitlab\builds\6d255f49\0\games\funkidracing.tmp\CI_SERVER_TLS_CA_FILE" -Value "....masked...." -Encoding UTF8 -Force
$CI_SERVER_TLS_CA_FILE="\Users\gitlab\builds\6d255f49\0\games\funkidracing.tmp\CI_SERVER_TLS_CA_FILE"
$env:CI_SERVER_TLS_CA_FILE=$CI_SERVER_TLS_CA_FILE
$CI="true"
$env:CI=$CI
$GITLAB_CI="true"
$env:GITLAB_CI=$GITLAB_CI
$CI_SERVER_NAME="GitLab"
$env:CI_SERVER_NAME=$CI_SERVER_NAME
$CI_SERVER_VERSION="9.2.6"

Environment description

gitlabs-iMac:unity gitlab$ /usr/local/bin/gitlab-runner --version
Version:      9.2.1
Git revision: f018144
Git branch:
GO version:   go1.7.5
Built:        Sat, 17 Jun 2017 16:57:24 +0000
OS/Arch:      darwin/amd64

gitlabs-iMac:unity gitlab$ cat ~/.gitlab-runner/config.toml
concurrent = 3
check_interval = 0

[[runners]]
  name = "hackintosh"
  url = "https://.../"
  token = "..."
  executor = "shell"
  shell = "powershell"
  [runners.cache]

gitlabs-iMac:unity gitlab$ powershell --version
powershell v6.0.0-beta.2
GitLab 9.2.6
GitLab Shell 5.0.4
GitLab Workhorse v2.0.0
GitLab API v4
Git 2.11.1
Ruby 2.3.3p222
Rails 4.2.8
postgresql 9.6.1
Edited by Artūras Šlajus