git-docker/windows/clone.ps1

65 lines
1.6 KiB
PowerShell
Raw Normal View History

2018-09-11 18:06:54 +00:00
$ErrorActionPreference = 'Stop';
2018-09-11 23:06:41 +00:00
# HACK: no clue how to set the PATH inside the Dockerfile,
# so am setting it here instead. This is not idea.
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
2018-09-11 18:06:54 +00:00
# if the workspace is set we should make sure
# it is the current working directory.
if ($Env:DRONE_WORKSPACE) {
cd $Env:DRONE_WORKSPACE
}
# if the netrc enviornment variables exist, write
# the netrc file.
if ($Env:DRONE_NETRC_MACHINE) {
2018-12-14 01:52:14 +00:00
@"
machine $Env:DRONE_NETRC_MACHINE
login $Env:DRONE_NETRC_USERNAME
password $Env:DRONE_NETRC_PASSWORD
"@ > (Join-Path $Env:USERPROFILE '_netrc');
2018-09-11 18:06:54 +00:00
}
# configure git global behavior and parameters via the
# following environment variables:
if ($Env:PLUGIN_SKIP_VERIFY) {
$Env:GIT_SSL_NO_VERIFY = "true"
}
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
} else {
$Env:GIT_AUTHOR_NAME = "drone"
}
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
} else {
$Env:GIT_AUTHOR_NAME = 'drone@localhost'
}
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
$Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
# invoke the sub-script based on the drone event type.
# TODO we should ultimately look at the ref, since
# we need something compatible with deployment events.
switch ($Env:DRONE_BUILD_EVENT) {
"pull_request" {
2019-03-26 11:09:53 +00:00
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
2018-09-11 18:06:54 +00:00
break
}
"tag" {
2018-09-11 23:06:41 +00:00
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
2018-09-11 18:06:54 +00:00
break
}
default {
2018-09-11 23:06:41 +00:00
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
2018-09-11 18:06:54 +00:00
break
}
2019-03-26 11:09:53 +00:00
}