25 Commits

Author SHA1 Message Date
Brad Rydzewski a01800911c Fix powershell condition [CI SKIP] 2019-04-18 17:15:40 -07:00
Brad Rydzewski dddd99c40a Fix incorrect committer email [CI SKIP] 2019-04-18 16:59:02 -07:00
Brad Rydzewski a2c9b60089 Set the default windows variables [CI SKIP] 2019-04-18 16:54:04 -07:00
Brad Rydzewski a818535cfc Merge pull requests instead of rebase [CI SKIP] 2019-04-18 16:37:00 -07:00
Brad Rydzewski 584c0ee731 Merge pull request #14 from drpebcak/windows-pr-clone [CI SKIP]
fix ref variable usage
2019-04-18 16:29:42 -07:00
Taylor Price 68c60db9d5 fix ref variable usage 2019-04-18 11:57:37 -07:00
Brad Rydzewski 214a9d2492 embed files [CI SKIP] 2019-04-10 22:10:20 -07:00
Brad Rydzewski 059b7b18b0 Merge remote-tracking branch 'origin/master' 2019-04-10 22:03:22 -07:00
Brad Rydzewski 5f6bea6871 embed scripts 2019-04-10 22:03:12 -07:00
Brad Rydzewski b7b05f526c Merge pull request #12 from davherrmann/fix-windows-pull-request-clone
Fix pull request clone on Windows
2019-04-10 18:54:20 -07:00
David Herrmann 1ef9ff7e4d Fix pull request clone on Windows 2019-03-26 12:09:53 +01:00
Brad Rydzewski 3174a3cfd3 Merge pull request #11 from donny-dont/windows-ci
Add Windows CI
2019-03-15 15:22:07 -07:00
Brad Rydzewski 6dca8731a7 Merge pull request #10 from donny-dont/windows-dockerfiles [ci skip]
Update dockerfiles and manifest for windows
2019-03-15 15:20:22 -07:00
Don 1b0a44afc1 Add Windows CI 2019-03-15 15:17:38 -07:00
Don 1fc5fded5a Update dockerfiles and manifest for windows 2019-03-15 15:12:21 -07:00
Brad Rydzewski e7468f9a19 Merge remote-tracking branch 'origin/master' 2019-01-21 12:31:08 -08:00
Brad Rydzewski 419d29331d fix set user/email 2019-01-21 12:30:42 -08:00
Brad Rydzewski 7bb19442db Merge pull request #6 from donny-dont/fix-stuff [ci skip]
Fix netrc on Windows
2018-12-14 18:28:18 -08:00
Brad Rydzewski f290e93029 Merge pull request #3 from carlwgeorge/lfs
Add git-lfs to Linux images
2018-12-14 18:21:43 -08:00
Brad Rydzewski 16d4b8019f Merge remote-tracking branch 'origin/master' 2018-12-14 18:10:39 -08:00
Brad Rydzewski 7a6564cc28 fix issue with missing author and email 2018-12-14 18:10:09 -08:00
Don 95ae01e6dd Fix netrc and log to the console 2018-12-13 17:52:14 -08:00
Carl George 1bd2db0719 Add git-lfs to Linux images 2018-11-28 20:09:36 -06:00
Brad Rydzewski 6b831bd981 Merge pull request #1 from josmo/promote-tag-fix
Adding check of refs to handle promotions of tags
2018-11-13 09:48:46 -08:00
Joachim Hill-Grannec 0014fd5f14 Adding check of refs to handle promotions of tags 2018-11-10 16:02:31 -05:00
22 changed files with 594 additions and 55 deletions
+74
View File
@@ -0,0 +1,74 @@
local windows_pipe = '\\\\\\\\.\\\\pipe\\\\docker_engine';
local windows_pipe_volume = 'docker_pipe';
local versions = [
//'1803',
'1809',
];
local trigger = {
ref: [
'refs/heads/master',
'refs/tags/**',
],
};
local pipeline_name(version) = 'Windows ' + version;
local pipeline(version, arch) = {
kind: 'pipeline',
name: pipeline_name(version),
platform: {
os: 'windows',
arch: arch,
version: version,
},
steps: [{
name: 'git',
image: 'plugins/docker:windows-1809', // TODO: This should just use the manifest
settings: {
repo: 'drone/git',
dockerfile: 'docker/Dockerfile.windows.' + version,
auto_tag: true,
auto_tag_suffix: 'windows-' + version + '-' + arch,
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
// Windows specific options
daemon_off: true,
purge: 'false', // TODO: Fix bug where setting false won't generate the yaml value
},
volumes: [{ name: windows_pipe_volume, path: windows_pipe }],
}],
volumes: [{ name: windows_pipe_volume, host: { path: windows_pipe } }],
trigger: trigger,
};
[
pipeline(version, 'amd64')
for version in versions
] + [
{
kind: 'pipeline',
name: 'Image Manifest',
steps: [{
name: 'manifest',
image: 'plugins/manifest',
settings: {
spec: 'docker/manifest.tmpl',
ignore_missing: true,
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
}],
depends_on: [
pipeline_name(version)
for version in versions
],
trigger: trigger,
},
]
+65
View File
@@ -0,0 +1,65 @@
---
kind: pipeline
name: Windows 1809
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: git
image: plugins/docker:windows-1809
settings:
auto_tag: true
auto_tag_suffix: windows-1809-amd64
daemon_off: true
dockerfile: docker/Dockerfile.windows.1809
password:
from_secret: docker_password
purge: false
repo: drone/git
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
---
kind: pipeline
name: Image Manifest
platform:
os: linux
arch: amd64
steps:
- name: manifest
image: plugins/manifest
settings:
ignore_missing: true
password:
from_secret: docker_password
spec: docker/manifest.tmpl
username:
from_secret: docker_username
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
depends_on:
- Windows 1809
...
+24
View File
@@ -0,0 +1,24 @@
# drone-git
Drone plugin to clone `git` repositories.
## Build
Build the Docker image with the following commands:
```
docker build --rm -f docker/Dockerfile.linux.amd64 -t drone/git .
```
## Usage
Clone a commit:
```
docker run --rm \
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
-e DRONE_BUILD_EVENT=push \
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \
-e DRONE_COMMIT_BRANCH=master \
drone/git
```
+2 -2
View File
@@ -1,5 +1,5 @@
FROM alpine:3.6 FROM alpine:3.7
RUN apk add --no-cache ca-certificates git openssh curl perl RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM arm32v6/alpine:3.6 FROM arm32v6/alpine:3.7
RUN apk add --no-cache ca-certificates git openssh curl perl RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM arm32v6/alpine:3.6 FROM arm32v6/alpine:3.7
RUN apk add --no-cache ca-certificates git openssh curl perl RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM arm64v8/alpine:3.6 FROM arm64v8/alpine:3.7
RUN apk add --no-cache ca-certificates git openssh curl perl RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM arm32v6/alpine:3.6 FROM arm32v6/alpine:3.7
RUN apk add --no-cache ca-certificates git openssh curl perl RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]
+2 -2
View File
@@ -1,5 +1,5 @@
FROM arm64v8/alpine:3.6 FROM arm64v8/alpine:3.7
RUN apk add --no-cache ca-certificates git openssh curl perl RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]
+7 -7
View File
@@ -1,11 +1,13 @@
FROM microsoft/windowsservercore:1803 AS git # escape=`
FROM mcr.microsoft.com/windows/servercore:1803 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \ Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git Expand-Archive git.zip -DestinationPath C:\git;
FROM microsoft/powershell:nanoserver-1803 FROM mcr.microsoft.com/powershell:nanoserver-1803
COPY --from=git /git /git COPY --from=git /git /git
ADD windows/* /bin/ ADD windows/* /bin/
@@ -14,7 +16,5 @@ ADD windows/* /bin/
USER ContainerAdministrator USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell" RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
ENV HOME C:\\Users\\ContainerAdministrator
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ] CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
@@ -1,11 +1,13 @@
FROM microsoft/windowsservercore:1709 AS git # escape=`
FROM mcr.microsoft.com/windows/servercore:1809 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \ Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git Expand-Archive git.zip -DestinationPath C:\git;
FROM microsoft/powershell:nanoserver-1709 FROM mcr.microsoft.com/powershell:nanoserver-1809
COPY --from=git /git /git COPY --from=git /git /git
ADD windows/* /bin/ ADD windows/* /bin/
@@ -14,7 +16,5 @@ ADD windows/* /bin/
USER ContainerAdministrator USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell" RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
ENV HOME C:\\Users\\ContainerAdministrator
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ] CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
+10 -4
View File
@@ -24,8 +24,14 @@ manifests:
architecture: arm architecture: arm
os: linux os: linux
- -
image: drone/git:windows-1803 image: drone/git:windows-1803-amd64
platform: platform:
architecture: arm architecture: amd64
os: linux os: windows
os.version: 10.0.17134.165 version: 1803
-
image: drone/git:windows-1809-amd64
platform:
architecture: amd64
os: windows
version: 1809
+18 -6
View File
@@ -32,18 +32,30 @@ fi
# configure git global behavior and parameters via the # configure git global behavior and parameters via the
# following environment variables: # following environment variables:
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME=drone}
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost}
export GIT_COMMITTER_NAME=${GIT_AUTHOR_NAME}
export GIT_COMMITTER_EMAIL=${GIT_AUTHOR_EMAIL}
# GIT_SSL_NO_VERIFY=
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
export DRONE_COMMIT_AUTHOR_NAME=drone
fi
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
fi
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
# invoke the sub-script based on the drone event type. # invoke the sub-script based on the drone event type.
# TODO we should ultimately look at the ref, since # TODO we should ultimately look at the ref, since
# we need something compatible with deployment events. # we need something compatible with deployment events.
case $DRONE_BUILD_EVENT in CLONE_TYPE=$DRONE_BUILD_EVENT
case $DRONE_COMMIT_REF in
refs/tags/* ) CLONE_TYPE=tag ;;
esac
case $CLONE_TYPE in
pull_request) pull_request)
clone-pull-request clone-pull-request
;; ;;
+1 -1
View File
@@ -17,4 +17,4 @@ git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
git checkout ${DRONE_COMMIT_BRANCH} git checkout ${DRONE_COMMIT_BRANCH}
git fetch origin ${DRONE_COMMIT_REF}: git fetch origin ${DRONE_COMMIT_REF}:
git rebase ${DRONE_COMMIT_SHA} git merge ${DRONE_COMMIT_SHA}
+2
View File
@@ -1 +1,3 @@
package posix package posix
//go:generate go run ../scripts/includetext.go --input=clone --input=clone-commit --input=clone-pull-request --input=clone-tag --package=posix --output=posix_gen.go
+137
View File
@@ -0,0 +1,137 @@
package posix
// DO NOT EDIT. This file is automatically generated.
// Contents of clone
const Clone = `#!/bin/sh
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
cd ${DRONE_WORKSPACE}
fi
# if the netrc enviornment variables exist, write
# the netrc file.
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
cat <<EOF > /root/.netrc
machine ${DRONE_NETRC_MACHINE}
login ${DRONE_NETRC_USERNAME}
password ${DRONE_NETRC_PASSWORD}
EOF
fi
# if the ssh_key environment variable exists, write
# the ssh key and add the netrc machine to the
# known hosts file.
if [[ ! -z "${SSH_KEY}" ]]; then
mkdir /root/.ssh
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
touch /root/.ssh/known_hosts
chmod 600 /root/.ssh/known_hosts
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
fi
# configure git global behavior and parameters via the
# following environment variables:
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
export DRONE_COMMIT_AUTHOR_NAME=drone
fi
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
fi
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_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.
CLONE_TYPE=$DRONE_BUILD_EVENT
case $DRONE_COMMIT_REF in
refs/tags/* ) CLONE_TYPE=tag ;;
esac
case $CLONE_TYPE in
pull_request)
clone-pull-request
;;
tag)
clone-tag
;;
*)
clone-commit
;;
esac
`
// Contents of clone-commit
const CloneCommit = `#!/bin/sh
FLAGS=""
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
FLAGS="--depth=${PLUGIN_DEPTH}"
fi
if [ ! -d .git ]; then
git init
git remote add origin ${DRONE_REMOTE_URL}
fi
set -e
set -x
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
git checkout ${DRONE_COMMIT_SHA} -b ${DRONE_COMMIT_BRANCH}
`
// Contents of clone-pull-request
const ClonePullRequest = `#!/bin/sh
FLAGS=""
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
FLAGS="--depth=${PLUGIN_DEPTH}"
fi
if [ ! -d .git ]; then
git init
git remote add origin ${DRONE_REMOTE_URL}
fi
set -e
set -x
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
git checkout ${DRONE_COMMIT_BRANCH}
git fetch origin ${DRONE_COMMIT_REF}:
git merge ${DRONE_COMMIT_SHA}
`
// Contents of clone-tag
const CloneTag = `#!/bin/sh
FLAGS=""
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
FLAGS="--depth=${PLUGIN_DEPTH}"
fi
if [ ! -d .git ]; then
git init
git remote add origin ${DRONE_REMOTE_URL}
fi
set -e
set -x
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
git checkout -qf FETCH_HEAD
`
+87
View File
@@ -0,0 +1,87 @@
// +build ignore
package main
import (
"bytes"
"flag"
"io/ioutil"
"log"
"path/filepath"
"strings"
"text/template"
)
var (
input stringSlice
output string
name string
)
func main() {
flag.Var(&input, "input", "input files")
flag.StringVar(&output, "output", "", "output file")
flag.StringVar(&name, "package", "", "package name")
flag.Parse()
var files []File
for _, file := range input {
out, err := ioutil.ReadFile(file)
if err != nil {
log.Fatalln(err)
}
files = append(files, File{
Name: file,
Slug: slugify(file),
Data: string(out),
})
}
data := map[string]interface{}{
"Files": files,
"Package": name,
}
buf := new(bytes.Buffer)
err := tmpl.Execute(buf, data)
if err != nil {
log.Fatalln(err)
}
ioutil.WriteFile(output, buf.Bytes(), 0644)
}
func slugify(s string) string {
ext := filepath.Ext(s)
s = strings.TrimSuffix(s, ext)
s = strings.Title(s)
s = strings.ReplaceAll(s, "-", "")
s = strings.ReplaceAll(s, "_", "")
return s
}
type stringSlice []string
func (s *stringSlice) String() string {
return strings.Join(*s, ",")
}
func (s *stringSlice) Set(value string) error {
*s = append(*s, value)
return nil
}
type File struct {
Name string
Data string
Slug string
}
var tmpl = template.Must(template.New("_").Parse(`package {{ .Package }}
// DO NOT EDIT. This file is automatically generated.
{{ range .Files -}}
// Contents of {{ .Name }}
const {{ .Slug }} = ` + "`{{ .Data }}`" + `
{{ end -}}`))
+6 -2
View File
@@ -5,9 +5,13 @@ if ($Env:PLUGIN_DEPTH) {
} }
if (!(Test-Path .git)) { if (!(Test-Path .git)) {
Write-Host 'git init';
git init git init
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
git remote add origin $Env:DRONE_REMOTE_URL git remote add origin $Env:DRONE_REMOTE_URL
} }
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:" Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
+2 -2
View File
@@ -12,5 +12,5 @@ if (!(Test-Path .git)) {
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:" git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
git checkout $Env:DRONE_COMMIT_BRANCH git checkout $Env:DRONE_COMMIT_BRANCH
git fetch origin $Env:DRONE_COMMIT_REF: git fetch origin "${Env:DRONE_COMMIT_REF}:"
git rebase $Env:DRONE_COMMIT_SHA git merge $Env:DRONE_COMMIT_SHA
+12 -12
View File
@@ -15,11 +15,11 @@ if ($Env:DRONE_WORKSPACE) {
# the netrc file. # the netrc file.
if ($Env:DRONE_NETRC_MACHINE) { if ($Env:DRONE_NETRC_MACHINE) {
@"
$netrc=[string]::Format("{0}\_netrc",$Env:HOME); machine $Env:DRONE_NETRC_MACHINE
"machine $Env:CI_NETRC_MACHINE" >> $netrc; login $Env:DRONE_NETRC_USERNAME
"login $Env:CI_NETRC_USERNAME" >> $netrc; password $Env:DRONE_NETRC_PASSWORD
"password $Env:CI_NETRC_PASSWORD" >> $netrc; "@ > (Join-Path $Env:USERPROFILE '_netrc');
} }
# configure git global behavior and parameters via the # configure git global behavior and parameters via the
@@ -29,16 +29,16 @@ if ($Env:PLUGIN_SKIP_VERIFY) {
$Env:GIT_SSL_NO_VERIFY = "true" $Env:GIT_SSL_NO_VERIFY = "true"
} }
if ($Env:DRONE_COMMIT_AUTHOR_NAME) { if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
} else {
$Env:GIT_AUTHOR_NAME = "drone" $Env:GIT_AUTHOR_NAME = "drone"
} else {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
} }
if ($Env:DRONE_COMMIT_AUTHOR_NAME) { if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME $Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
} else { } else {
$Env:GIT_AUTHOR_NAME = 'drone@localhost' $Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
} }
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME $Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
@@ -50,7 +50,7 @@ $Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
switch ($Env:DRONE_BUILD_EVENT) { switch ($Env:DRONE_BUILD_EVENT) {
"pull_request" { "pull_request" {
Invoke-Expression "${PSScriptRoot}\clone-pull-reqest.ps1" Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
break break
} }
"tag" { "tag" {
+3
View File
@@ -0,0 +1,3 @@
package windows
//go:generate go run ../scripts/includetext.go --input=clone.ps1 --input=clone-commit.ps1 --input=clone-pull-request.ps1 --input=clone-tag.ps1 --package=windows --output=windows_gen.go
+125
View File
@@ -0,0 +1,125 @@
package windows
// DO NOT EDIT. This file is automatically generated.
// Contents of clone.ps1
const Clone = `$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) {
$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" {
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
break
}
"tag" {
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
break
}
default {
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
break
}
}
`
// Contents of clone-commit.ps1
const CloneCommit = `
Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}
if (!(Test-Path .git)) {
Write-Host 'git init';
git init
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
git remote add origin $Env:DRONE_REMOTE_URL
}
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
`
// Contents of clone-pull-request.ps1
const ClonePullRequest = `
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
`
// Contents of clone-tag.ps1
const CloneTag = `
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
`