git-docker/windows/clone.ps1
2019-04-18 17:15:40 -07:00

65 lines
1.7 KiB
PowerShell

$ErrorActionPreference = 'Stop';
# 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'
# 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) {
@"
machine $Env:DRONE_NETRC_MACHINE
login $Env:DRONE_NETRC_USERNAME
password $Env:DRONE_NETRC_PASSWORD
"@ > (Join-Path $Env:USERPROFILE '_netrc');
}
# 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 -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
$Env:GIT_AUTHOR_NAME = "drone"
} else {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
}
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
} else {
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
}
$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" {
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
break
}
"tag" {
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
break
}
default {
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
break
}
}