29 Commits

Author SHA1 Message Date
Shubham Agrawal e82207b591 Fix UT 2021-02-05 20:39:03 +05:30
Shubham Agrawal 21eadbab5b Fixed test 2021-02-05 20:35:55 +05:30
Shubham Agrawal b3e3302ecf Added AWS codecommit support using access & secret keys 2021-02-05 20:02:25 +05:30
Brad Rydzewski d2d831e671 Merge pull request #35 from r3pek/master
Upgrade to alpine 3.12 to support TLS 1.3
2020-12-09 16:13:46 -05:00
Carlos Mogas da Silva 3fece4c3ef Upgrade to alpine 3.12 to support TLS 1.3 2020-11-26 23:53:24 +00:00
Brad Rydzewski 3f12c6de5c Merge pull request #33 from shubham149/ssh_key
Added DRONE_SSH_KEY for ssh key environment variable
2020-11-06 09:19:05 -05:00
Brad Rydzewski 6950125511 rename ssh_key to DRONE_SSH_KEY 2020-11-06 09:10:13 -05:00
Shubham Agrawal e8ff70dc6a Added DRONE_SSH_KEY for ssh key environment variable 2020-11-04 12:38:22 +05:30
Brad Rydzewski 4148c5c886 allow depth when cloning head commit in branch 2020-10-29 10:27:49 -04:00
Brad Rydzewski fc019e513c fix checkout by branch 2020-10-29 10:18:31 -04:00
Brad Rydzewski d0bca2a1f7 Merge pull request #32 from shubham149/clone_branch
Support cloning a branch without commit ID
2020-10-29 10:11:23 -04:00
Shubham Agrawal dd96a5a670 Support cloning a branch without commit 2020-10-29 16:07:40 +05:30
Brad Rydzewski 1cc29870a1 added 1909 image to manifest 2020-05-03 15:03:56 -04:00
Brad Rydzewski e4396e7c26 added 1909 dockerfile 2020-05-03 15:02:48 -04:00
Brad Rydzewski a5164ab012 handle empty branch 2020-04-28 18:54:00 -04:00
Brad Rydzewski 1af95e7756 Merge pull request #19 from andrewrynhard/promote
feat: add support for promoting pull requests
2019-09-18 10:18:38 -07:00
Andrew Rynhard 570050ebdd feat: add support for promoting pull requests
Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2019-08-28 03:11:52 +00:00
Brad Rydzewski da8b0f06c8 support semver in manifest [ci skip] 2019-08-06 14:54:41 -07:00
Brad Rydzewski 3aa6fca781 add starlark script [ci skip] 2019-08-06 14:32:02 -07:00
Brad Rydzewski 14ed083e1c add linux builds to pipeline 2019-08-06 14:21:32 -07:00
Brad Rydzewski 5f949df9c8 add 1809 windows build 2019-08-06 13:07:02 -07:00
Brad Rydzewski 47ba7912a0 attempt windows 1903 build 2019-08-06 10:06:46 -07:00
Brad Rydzewski 8f0278c190 add 1809 build using ssh driver [ci skip] 2019-08-04 22:26:47 -07:00
Brad Rydzewski 7eaff99357 prepare for windows 1903 [ci skip] 2019-08-04 21:37:08 -07:00
Brad Rydzewski 5b0a12bcb3 update changelog for 1.1.0 [ci skip] 2019-04-19 08:18:08 -07:00
Brad Rydzewski caad046d7a added changelog file [ci skip] 2019-04-19 08:16:55 -07:00
Brad Rydzewski 5159feae9f update embedded files [CI SKIP] 2019-04-19 08:09:55 -07:00
Brad Rydzewski c2b692bf44 Merge pull request #16 from drone/set-default-win-variables [CI SKIP]
Fix powershell condition [CI SKIP]
2019-04-18 17:16:15 -07:00
Brad Rydzewski ad2dad7b8a Merge pull request #15 from drone/set-default-win-variables
Set the default windows variables [CI SKIP]
2019-04-18 17:03:10 -07:00
20 changed files with 450 additions and 218 deletions
+130
View File
@@ -0,0 +1,130 @@
# this starlark script should be used to generate the .drone.yml
# configuration file.
def main(ctx):
# TODO consider running unit tests before building and
# publishing docker images.
before = {}
stages = [
linux('arm'),
linux('arm64'),
linux('amd64'),
windows('1903'),
windows('1809'),
]
after = manifest()
# the after stage should only execute after all previous
# stages complete. this builds the dependency graph.
for stage in stages:
after['depends_on'].append(stage['name'])
return stages + [ after ]
# create a pipeline stage responsible for building and
# publishing the Docker image on linux.
def linux(arch):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'linux-%s' % arch,
'platform': {
'os': 'linux',
'arch': arch,
},
'steps': [
{
'name': 'build',
'image': 'golang:1.10',
'commands': [
'cd posix',
'tar -xf fixtures.tar -C /',
'go test -v',
],
},
{
'name': 'publish',
'image': 'plugins/docker',
'settings': {
'auto_tag': 'true',
'auto_tag_suffix': 'linux-%s' % arch,
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
'password': {
'from_secret': 'docker_password',
},
'repo': 'drone/git',
'username': 'drone',
},
'when': {
'event': ['push', 'tag']
}
}
]
}
# create a pipeline stage responsible for building and
# publishing the Docker image on windows. The windows stage
# uses an ssh runner, as opposed to a docker runner.
def windows(version):
return {
'kind': 'pipeline',
'type': 'ssh',
'name': 'windows-%s-amd64' % version,
'platform': {
'os': 'windows'
},
'server': {
'host': { 'from_secret': 'windows_server_%s' % version },
'user': { 'from_secret': 'windows_username' },
'password': { 'from_secret': 'windows_password' },
},
'steps': [
{
'name': 'build',
'environment': {
'USERNAME': { 'from_secret': 'docker_username' },
'PASSWORD': { 'from_secret': 'docker_password' },
},
# TODO these commands build and publish the latest
# docker tag regardless of git tag.
'commands': [
'docker login -u $env:USERNAME -p $env:PASSWORD',
'docker build -f docker/Dockerfile.windows.%s -t drone/git:windows-%s-amd64 .' % (version, version),
'docker push drone/git:windows-%s-amd64' % version,
],
},
],
'trigger': {
'event': ['push']
}
}
# create a pipeline stage responsible for creating and
# publishing a docker manifest to the registry.
def manifest():
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'manifest',
'steps': [
{
'name': 'manifest',
'image': 'plugins/manifest',
'settings': {
'auto_tag': 'true',
'username': 'drone',
'password': {
'from_secret': 'docker_password'
},
'spec': 'docker/manifest.tmpl',
'ignore_missing': 'true',
},
},
],
'depends_on': [],
'trigger': {
'event': ['push', 'tag']
}
}
-74
View File
@@ -1,74 +0,0 @@
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
@@ -1,65 +0,0 @@
---
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
...
+148 -51
View File
@@ -1,29 +1,33 @@
---
# this file is automatically generated. DO NOT EDIT
kind: pipeline
type: docker
name: linux-amd64
platform:
os: linux
arch: amd64
os: linux
steps:
- name: test
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: push
image: plugins/docker
- name: publish
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: docker/Dockerfile.linux.amd64
password:
$secret: password
repo: drone/git
username: drone
auto_tag: "true"
auto_tag_suffix: linux-amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- push
@@ -31,30 +35,32 @@ steps:
---
kind: pipeline
type: docker
name: linux-arm64
platform:
os: linux
arch: arm64
os: linux
steps:
- name: test
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: push
image: plugins/docker:linux-arm64
- name: publish
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: docker/Dockerfile.linux.arm64
password:
$secret: password
repo: drone/git
username: drone
auto_tag: "true"
auto_tag_suffix: linux-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- push
@@ -62,30 +68,32 @@ steps:
---
kind: pipeline
type: docker
name: linux-arm
platform:
os: linux
arch: arm
os: linux
steps:
- name: test
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: push
image: plugins/docker:linux-arm
- name: publish
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm
dockerfile: docker/Dockerfile.linux.arm
password:
$secret: password
repo: drone/git
username: drone
auto_tag: "true"
auto_tag_suffix: linux-arm
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- push
@@ -93,37 +101,126 @@ steps:
---
kind: pipeline
name: after
type: ssh
name: windows-1909-amd64
platform:
os: linux
arch: amd64
os: windows
server:
host:
from_secret: windows_server_1909
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1909 -t drone/git:windows-1909-amd64 .
- docker push drone/git:windows-1909-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: ssh
name: windows-1903-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1903
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1903 -t drone/git:windows-1903-amd64 .
- docker push drone/git:windows-1903-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: ssh
name: windows-1809-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1809
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1809 -t drone/git:windows-1809-amd64 .
- docker push drone/git:windows-1809-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: docker
name: manifest
steps:
- name: manifest
image: plugins/manifest:1
image: plugins/manifest
settings:
ignore_missing: true
password:
$secret: password
auto_tag: "true"
ignore_missing: "true"
spec: docker/manifest.tmpl
username: drone
when:
branch:
- master
event:
- push
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger:
event:
- push
- tag
depends_on:
- linux-arm
- linux-arm64
- linux-amd64
---
kind: secret
type: external
data:
password: "drone/docker#password"
username: "drone/docker#username"
...
- linux-arm64
- linux-arm
- windows-1909-amd64
- windows-1903-amd64
- windows-1809-amd64
-2
View File
@@ -1,2 +0,0 @@
.drone.jsonnet
.drone.jsonnet.yml
+21
View File
@@ -0,0 +1,21 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
## [1.1.0]
### Added
- Ability to clone tags for promotion events from [@josmo](https://github.com/josme)
- Support for git lfs in base images from [@carlwgeorge](https://github.com/carlwgeorge)
- Support for windows 1803 from [@donny-dont](https://github.com/donny-dont)
- Support for windows 1809 from [@donny-dont](https://github.com/donny-dont)
### Fixed
- Fixed error merging when missing email from [@bradrydzewski](https://github.com/bradrydzewski)
- Fixed empty ref on windows from [@drpebcak](https://github.com/drpebcak)
+27 -1
View File
@@ -1,5 +1,31 @@
FROM alpine:3.7
FROM alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ENV GLIBC_VER=2.31-r0
RUN apk --no-cache add \
binutils \
curl \
&& curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \
&& apk add --no-cache \
glibc-${GLIBC_VER}.apk \
glibc-bin-${GLIBC_VER}.apk \
&& curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.1.24.zip -o awscliv2.zip \
&& unzip awscliv2.zip \
&& aws/install \
&& rm -rf \
awscliv2.zip \
aws \
/usr/local/aws-cli/v2/*/dist/aws_completer \
/usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \
/usr/local/aws-cli/v2/*/dist/awscli/examples \
&& apk --no-cache del \
binutils \
curl \
&& rm glibc-${GLIBC_VER}.apk \
&& rm glibc-bin-${GLIBC_VER}.apk \
&& rm -rf /var/cache/apk/*
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]
+1 -1
View File
@@ -1,4 +1,4 @@
FROM arm32v6/alpine:3.7
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
+1 -1
View File
@@ -1,4 +1,4 @@
FROM arm32v6/alpine:3.7
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
+1 -1
View File
@@ -1,4 +1,4 @@
FROM arm64v8/alpine:3.7
FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
+1 -1
View File
@@ -1,4 +1,4 @@
FROM arm32v6/alpine:3.7
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
+1 -1
View File
@@ -1,4 +1,4 @@
FROM arm64v8/alpine:3.7
FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
+20
View File
@@ -0,0 +1,20 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1903 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
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;
FROM mcr.microsoft.com/powershell:nanoserver-1903
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
+20
View File
@@ -0,0 +1,20 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1909 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
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;
FROM mcr.microsoft.com/powershell:nanoserver-1909
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
+25 -7
View File
@@ -1,37 +1,55 @@
image: drone/git:latest
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: drone/git:linux-amd64
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: drone/git:linux-arm64
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
variant: v8
architecture: arm64
os: linux
-
image: drone/git:linux-arm
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
-
image: drone/git:linux-arm
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux
-
image: drone/git:windows-1803-amd64
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
platform:
architecture: amd64
os: windows
version: 1803
-
image: drone/git:windows-1809-amd64
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows
version: 1809
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform:
architecture: amd64
os: windows
version: 1903
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
+17 -2
View File
@@ -19,9 +19,9 @@ fi
# the ssh key and add the netrc machine to the
# known hosts file.
if [[ ! -z "${SSH_KEY}" ]]; then
if [[ ! -z "${DRONE_SSH_KEY}" ]]; then
mkdir /root/.ssh
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
echo -n "$DRONE_SSH_KEY" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
touch /root/.ssh/known_hosts
@@ -29,6 +29,18 @@ if [[ ! -z "${SSH_KEY}" ]]; then
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
fi
# AWS codecommit support using AWS access key & secret key
# Refer: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html
if [[ ! -z "$DRONE_AWS_ACCESS_KEY" ]]; then
aws configure set aws_access_key_id $DRONE_AWS_ACCESS_KEY
aws configure set aws_secret_access_key $DRONE_AWS_SECRET_KEY
aws configure set default.region $DRONE_AWS_REGION
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
fi
# configure git global behavior and parameters via the
# following environment variables:
@@ -53,6 +65,9 @@ export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
CLONE_TYPE=$DRONE_BUILD_EVENT
case $DRONE_COMMIT_REF in
refs/tags/* ) CLONE_TYPE=tag ;;
refs/pull/* ) CLONE_TYPE=pull_request ;;
refs/pull-request/* ) CLONE_TYPE=pull_request ;;
refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
esac
case $CLONE_TYPE in
+24
View File
@@ -10,6 +10,30 @@ if [ ! -d .git ]; then
git remote add origin ${DRONE_REMOTE_URL}
fi
# the branch may be empty for certain event types,
# such as github deployment events. If the branch
# is empty we checkout the sha directly. Note that
# we intentially omit depth flags to avoid failed
# clones due to lack of history.
if [[ -z "${DRONE_COMMIT_BRANCH}" ]]; then
set -e
set -x
git fetch origin
git checkout -qf ${DRONE_COMMIT_SHA}
exit 0
fi
# the commit sha may be empty for builds that are
# manually triggered in Harness CI Enterprise. If
# the commit is empty we clone the branch.
if [[ -z "${DRONE_COMMIT_SHA}" ]]; then
set -e
set -x
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
git checkout -b ${DRONE_COMMIT_BRANCH} origin/${DRONE_COMMIT_BRANCH}
exit 0
fi
set -e
set -x
+1
View File
@@ -135,3 +135,4 @@ set -x
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
git checkout -qf FETCH_HEAD
`
+2 -2
View File
@@ -166,7 +166,7 @@ func TestPullRequest(t *testing.T) {
cmd.Dir = local
cmd.Env = []string{
fmt.Sprintf("DRONE_COMMIT_REF=%s", "refs/pull/14596/head"),
fmt.Sprintf("DRONE_COMMIT_BRANCH=%s", "master"),
fmt.Sprintf("DRONE_COMMIT_BRANCH=%s", "main"),
fmt.Sprintf("DRONE_COMMIT_SHA=%s", "26923a8f37933ccc23943de0d4ebd53908268582"),
fmt.Sprintf("DRONE_WORKSPACE=%s", local),
fmt.Sprintf("DRONE_REMOTE_URL=%s", remote),
@@ -195,7 +195,7 @@ func TestPullRequest(t *testing.T) {
t.Errorf("Want commit %s, got %s", want, got)
}
if want, got := "master", branch; got != want {
if want, got := "main", branch; got != want {
t.Errorf("Want branch %s, got %s", want, got)
}
+10 -9
View File
@@ -34,16 +34,16 @@ 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 {
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_NAME) {
$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_NAME = 'drone@localhost'
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
}
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
@@ -93,7 +93,7 @@ git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
const ClonePullRequest = `
Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}
if (!(Test-Path .git)) {
@@ -104,8 +104,8 @@ if (!(Test-Path .git)) {
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
git fetch origin "${Env:DRONE_COMMIT_REF}:"
git merge $Env:DRONE_COMMIT_SHA
`
// Contents of clone-tag.ps1
@@ -123,3 +123,4 @@ if (!(Test-Path .git)) {
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
git checkout -qf FETCH_HEAD
`