added powershell clone scripts
This commit is contained in:
parent
88b277aeda
commit
100815515c
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.drone.jsonnet
|
||||||
|
.drone.jsonnet.yml
|
13
windows/clone-commit.ps1
Normal file
13
windows/clone-commit.ps1
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path .git)) {
|
||||||
|
git init
|
||||||
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||||
|
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH
|
16
windows/clone-pull-request.ps1
Normal file
16
windows/clone-pull-request.ps1
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path .git)) {
|
||||||
|
git init
|
||||||
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||||
|
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||||
|
|
||||||
|
git fetch origin $Env:DRONE_COMMIT_REF:
|
||||||
|
git rebase $Env:DRONE_COMMIT_SHA
|
13
windows/clone-tag.ps1
Normal file
13
windows/clone-tag.ps1
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path .git)) {
|
||||||
|
git init
|
||||||
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
|
||||||
|
git checkout -qf FETCH_HEAD
|
60
windows/clone.ps1
Normal file
60
windows/clone.ps1
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
$ErrorActionPreference = 'Stop';
|
||||||
|
|
||||||
|
# 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) {
|
||||||
|
|
||||||
|
$netrc=[string]::Format("{0}\_netrc",$Env:HOME);
|
||||||
|
"machine $Env:CI_NETRC_MACHINE" >> $netrc;
|
||||||
|
"login $Env:CI_NETRC_USERNAME" >> $netrc;
|
||||||
|
"password $Env:CI_NETRC_PASSWORD" >> $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) {
|
||||||
|
$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" {
|
||||||
|
.\clone-pull-reqest.ps1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
"tag" {
|
||||||
|
.\clone-tag.ps1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
.\clone-commit.ps1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user