mirror of
https://github.com/drone/drone-git.git
synced 2026-06-13 18:42:15 +08:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f78e4f4674 | |||
| 36ff0a7a91 | |||
| 39d233b3d9 | |||
| d2b4c922fd | |||
| c40d9ffccc | |||
| f03006262c | |||
| 8070857203 | |||
| 3ccd78325a | |||
| 806bc25846 | |||
| 3d2cbbe9ba | |||
| f7b49aaf9e | |||
| be769618aa | |||
| 487521c8bc | |||
| 79700f47fe | |||
| 41c2120a63 | |||
| 9a0e8cc9d6 | |||
| 16f4dd8829 | |||
| e2f563e07f | |||
| 56e4928d73 | |||
| 70fe2c5f68 | |||
| f006eebba3 | |||
| 937b910001 | |||
| 6647ff2107 | |||
| a0b9eebc4f | |||
| e82207b591 | |||
| 21eadbab5b | |||
| b3e3302ecf | |||
| d2d831e671 | |||
| 3fece4c3ef | |||
| 3f12c6de5c | |||
| 6950125511 | |||
| e8ff70dc6a | |||
| 4148c5c886 | |||
| fc019e513c | |||
| d0bca2a1f7 | |||
| dd96a5a670 | |||
| 1cc29870a1 | |||
| e4396e7c26 | |||
| a5164ab012 | |||
| 1af95e7756 | |||
| 570050ebdd | |||
| da8b0f06c8 | |||
| 3aa6fca781 | |||
| 14ed083e1c | |||
| 5f949df9c8 | |||
| 47ba7912a0 | |||
| 8f0278c190 | |||
| 7eaff99357 | |||
| 5b0a12bcb3 | |||
| caad046d7a | |||
| 5159feae9f | |||
| c2b692bf44 | |||
| ad2dad7b8a |
@@ -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,
|
||||
},
|
||||
]
|
||||
@@ -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
|
||||
|
||||
...
|
||||
+128
-89
@@ -1,129 +1,168 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: linux-amd64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
- name: push
|
||||
image: plugins/docker
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: docker/Dockerfile.linux.amd64
|
||||
password:
|
||||
$secret: password
|
||||
repo: drone/git
|
||||
username: drone
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker:18
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.amd64
|
||||
repo: drone/git
|
||||
auto_tag: "true"
|
||||
auto_tag_suffix: linux-amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: linux-arm64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
pool:
|
||||
use: ubuntu_arm64
|
||||
|
||||
- name: push
|
||||
image: plugins/docker:linux-arm64
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
dockerfile: docker/Dockerfile.linux.arm64
|
||||
password:
|
||||
$secret: password
|
||||
repo: drone/git
|
||||
username: drone
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker:18
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.arm64
|
||||
repo: drone/git
|
||||
auto_tag: "true"
|
||||
auto_tag_suffix: linux-arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: linux-arm
|
||||
type: vm
|
||||
name: windows-1809
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm
|
||||
os: windows
|
||||
arch: amd64
|
||||
|
||||
pool:
|
||||
use: windows
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.windows.1809
|
||||
repo: drone/git
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
auto_tag: true
|
||||
auto_tag_suffix: windows-1809-amd64
|
||||
daemon_off: true
|
||||
purge: false
|
||||
|
||||
- name: push
|
||||
image: plugins/docker:linux-arm
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
dockerfile: docker/Dockerfile.linux.arm
|
||||
password:
|
||||
$secret: password
|
||||
repo: drone/git
|
||||
username: drone
|
||||
when:
|
||||
event:
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: after
|
||||
type: vm
|
||||
name: windows-ltsc2022
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
arch: amd64
|
||||
|
||||
pool:
|
||||
use: windows-2022
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.windows.ltsc2022
|
||||
repo: drone/git
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
auto_tag: true
|
||||
auto_tag_suffix: windows-ltsc2022-amd64
|
||||
daemon_off: true
|
||||
purge: false
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: manifest
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
steps:
|
||||
- name: manifest
|
||||
image: plugins/manifest:1
|
||||
settings:
|
||||
ignore_missing: true
|
||||
password:
|
||||
$secret: password
|
||||
spec: docker/manifest.tmpl
|
||||
username: drone
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- name: manifest
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: "true"
|
||||
ignore_missing: "true"
|
||||
spec: docker/manifest.tmpl
|
||||
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-amd64
|
||||
- linux-arm64
|
||||
- windows-1809
|
||||
- windows-ltsc2022
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
.drone.jsonnet
|
||||
.drone.jsonnet.yml
|
||||
@@ -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)
|
||||
@@ -16,6 +16,7 @@ Clone a commit:
|
||||
|
||||
```
|
||||
docker run --rm \
|
||||
-e DRONE_WORKSPACE=/drone \
|
||||
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
|
||||
-e DRONE_BUILD_EVENT=push \
|
||||
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
FROM alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
FROM alpine:3.20.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
|
||||
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
|
||||
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
|
||||
# USER drone:drone
|
||||
# RUN chmod -R 777 /home/drone
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM arm32v6/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM arm32v6/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
@@ -1,5 +1,11 @@
|
||||
FROM arm64v8/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
FROM arm64v8/alpine:3.20.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
|
||||
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
|
||||
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
|
||||
# USER drone:drone
|
||||
# RUN chmod -R 777 /home/drone
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM arm32v6/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM arm64v8/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
@@ -1,13 +1,13 @@
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1803 AS git
|
||||
FROM mcr.microsoft.com/windows/servercore:ltsc2022 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-1803
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-ltsc2022
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
+16
-22
@@ -1,37 +1,31 @@
|
||||
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
|
||||
platform:
|
||||
variant: v7
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: drone/git:linux-arm
|
||||
platform:
|
||||
variant: v6
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: drone/git: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-ltsc2022-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: ltsc2022
|
||||
+61
-12
@@ -1,14 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
|
||||
if [[ -n "${DRONE_WORKSPACE}" ]]; then
|
||||
# ensure the unprivileged drone user can write
|
||||
# to the workspace. This is required because
|
||||
# the workspace is a docker volume and is owned
|
||||
# by root.
|
||||
# sudo mkdir -p ${DRONE_WORKSPACE}
|
||||
# sudo chown drone:drone ${DRONE_WORKSPACE}
|
||||
|
||||
# ensure the workspace is the current working
|
||||
# directory. This should already be the case,
|
||||
# but we cd just to be safe.
|
||||
cd ${DRONE_WORKSPACE}
|
||||
fi
|
||||
|
||||
# force the home directory path.
|
||||
|
||||
# if [ "$HOME" != "/home/drone" ]; then
|
||||
# echo "[DEBUG] setting default home directory"
|
||||
# export HOME=/home/drone
|
||||
# fi
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
||||
cat <<EOF > /root/.netrc
|
||||
cat <<EOF > ${HOME}/.netrc
|
||||
machine ${DRONE_NETRC_MACHINE}
|
||||
login ${DRONE_NETRC_USERNAME}
|
||||
password ${DRONE_NETRC_PASSWORD}
|
||||
@@ -19,16 +36,28 @@ fi
|
||||
# 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
|
||||
if [[ ! -z "${DRONE_SSH_KEY}" ]]; then
|
||||
mkdir ${HOME}/.ssh
|
||||
echo -n "$DRONE_SSH_KEY" > ${HOME}/.ssh/id_rsa
|
||||
chmod 600 ${HOME}/.ssh/id_rsa
|
||||
|
||||
touch /root/.ssh/known_hosts
|
||||
chmod 600 /root/.ssh/known_hosts
|
||||
touch ${HOME}/.ssh/known_hosts
|
||||
chmod 600 ${HOME}/.ssh/known_hosts
|
||||
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,16 +82,36 @@ 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
|
||||
|
||||
git_clone_retry(){
|
||||
retries="${PLUGIN_RETRIES:-0}"
|
||||
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
|
||||
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Cloning with ${retries} retries"
|
||||
n=0
|
||||
until [ "$n" -gt "${retries}" ]; do
|
||||
$1 && return
|
||||
n=$((n+1))
|
||||
done
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
case $CLONE_TYPE in
|
||||
pull_request)
|
||||
clone-pull-request
|
||||
git_clone_retry clone-pull-request
|
||||
;;
|
||||
tag)
|
||||
clone-tag
|
||||
git_clone_retry clone-tag
|
||||
;;
|
||||
*)
|
||||
clone-commit
|
||||
git_clone_retry clone-commit
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -135,3 +135,4 @@ set -x
|
||||
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
|
||||
git checkout -qf FETCH_HEAD
|
||||
`
|
||||
|
||||
|
||||
+2
-2
@@ -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
@@ -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
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user