76 Commits

Author SHA1 Message Date
TP Honey 39d233b3d9 Update .drone.yml 2023-01-04 12:13:02 +00:00
TP Honey d2b4c922fd Update Dockerfile.windows.ltsc2022 2023-01-04 12:06:51 +00:00
TP Honey c40d9ffccc (maint) fix release for windows images (#49) 2023-01-04 11:54:02 +00:00
TP Honey f03006262c (maint) move to harness.drone.io (#48) 2023-01-04 10:25:17 +00:00
Julien Duchesne 8070857203 Add retries option (#43)
* Add `retries` option

It can be enabled this way:
```
clone:
  retries: 3
```
2021-11-23 10:23:52 +00:00
Brad Rydzewski 3ccd78325a revert to root due to npm issues 2021-05-14 09:09:58 -04:00
Brad Rydzewski 806bc25846 remove debug log entry 2021-05-06 14:40:28 -04:00
Brad Rydzewski 3d2cbbe9ba Merge remote-tracking branch 'origin/drone_non_root' into drone_non_root 2021-05-06 14:39:26 -04:00
Brad Rydzewski f7b49aaf9e update readme and annotate code with change 2021-05-06 14:39:13 -04:00
Shubham Agrawal be769618aa updated dockerfile for arm 2021-05-06 20:10:24 +05:30
Shubham Agrawal 487521c8bc provided 777 to /home/drone 2021-05-06 19:39:42 +05:30
Shubham Agrawal 79700f47fe Allow non-root user to run git clone plugin 2021-05-06 19:12:05 +05:30
Brad Rydzewski 41c2120a63 improve logs indicating HOME directory created 2021-05-04 21:17:22 -04:00
Brad Rydzewski 9a0e8cc9d6 create HOME directory if not exists 2021-05-04 21:16:15 -04:00
Brad Rydzewski 16f4dd8829 revert to alpine 3.12 due to dns issue 2021-05-04 21:07:07 -04:00
Brad Rydzewski e2f563e07f Merge pull request #38 from drone/update_git_version
Update git version to 2.30.2 to fix git clone vulnerability
2021-03-23 10:17:32 -04:00
Shubham Agrawal 56e4928d73 Update git version to 2.30.2 2021-03-19 20:31:24 +05:30
Shubham Agrawal 70fe2c5f68 Merge pull request #37 from drone/update_dockerfile
Use alpine package to install aws cl1 v1.18
2021-02-16 11:28:58 +05:30
Shubham Agrawal f006eebba3 addressed comments 2021-02-15 23:19:47 +05:30
Shubham Agrawal 937b910001 Using alpine package for aws cli 2021-02-10 17:11:16 +05:30
Shubham Agrawal 6647ff2107 Use pip to install aws cl1 v1.19.5 2021-02-10 16:06:42 +05:30
Shubham Agrawal a0b9eebc4f Merge pull request #36 from drone/aws_codecommit
Added AWS codecommit support using access & secret keys
2021-02-05 21:10:09 +05:30
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 a01800911c Fix powershell condition [CI SKIP] 2019-04-18 17:15:40 -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
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
25 changed files with 706 additions and 186 deletions
+128 -89
View File
@@ -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
-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)
+25
View File
@@ -0,0 +1,25 @@
# 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_WORKSPACE=/drone \
-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
```
+9 -3
View File
@@ -1,5 +1,11 @@
FROM alpine:3.6
RUN apk add --no-cache ca-certificates git openssh curl perl
FROM alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]
# 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"]
-5
View File
@@ -1,5 +0,0 @@
FROM arm32v6/alpine:3.6
RUN apk add --no-cache ca-certificates git openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]
-5
View File
@@ -1,5 +0,0 @@
FROM arm32v6/alpine:3.6
RUN apk add --no-cache ca-certificates git openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]
+8 -2
View File
@@ -1,5 +1,11 @@
FROM arm64v8/alpine:3.6
RUN apk add --no-cache ca-certificates git openssh curl perl
FROM arm64v8/alpine:3.12
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"]
-5
View File
@@ -1,5 +0,0 @@
FROM arm32v6/alpine:3.6
RUN apk add --no-cache ca-certificates git openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]
-5
View File
@@ -1,5 +0,0 @@
FROM arm64v8/alpine:3.6
RUN apk add --no-cache ca-certificates git openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]
@@ -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';"]
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; \
Expand-Archive git.zip -DestinationPath C:\git
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 microsoft/powershell:nanoserver-1709
FROM mcr.microsoft.com/powershell:nanoserver-1809
COPY --from=git /git /git
ADD windows/* /bin/
@@ -14,7 +16,5 @@ ADD windows/* /bin/
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
ENV HOME C:\\Users\\ContainerAdministrator
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
@@ -1,11 +1,13 @@
FROM microsoft/windowsservercore:1803 AS git
# escape=`
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.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \
Expand-Archive git.zip -DestinationPath C:\git
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 microsoft/powershell:nanoserver-1803
FROM mcr.microsoft.com/powershell:nanoserver-ltsc2022
COPY --from=git /git /git
ADD windows/* /bin/
@@ -14,7 +16,5 @@ ADD windows/* /bin/
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
ENV HOME C:\\Users\\ContainerAdministrator
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
+17 -17
View File
@@ -1,31 +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
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
variant: v7
architecture: arm
os: linux
architecture: amd64
os: windows
version: 1809
-
image: drone/git:linux-arm
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
platform:
variant: v6
architecture: arm
os: linux
-
image: drone/git:windows-1803
platform:
architecture: arm
os: linux
os.version: 10.0.17134.165
architecture: amd64
os: windows
version: ltsc2022
+79 -18
View File
@@ -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,38 +36,82 @@ 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:
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.
# TODO we should ultimately look at the ref, since
# 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 ;;
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
+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 -1
View File
@@ -17,4 +17,4 @@ git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
git checkout ${DRONE_COMMIT_BRANCH}
git fetch origin ${DRONE_COMMIT_REF}:
git rebase ${DRONE_COMMIT_SHA}
git merge ${DRONE_COMMIT_SHA}
+2
View File
@@ -1 +1,3 @@
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
+138
View File
@@ -0,0 +1,138 @@
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
`
+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)
}
+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)) {
Write-Host 'git init';
git init
Write-Host "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}:"
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH
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;
+3 -3
View File
@@ -1,7 +1,7 @@
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)) {
@@ -12,5 +12,5 @@ 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
+13 -13
View File
@@ -15,11 +15,11 @@ if ($Env:DRONE_WORKSPACE) {
# 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;
@"
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
@@ -29,16 +29,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
@@ -50,7 +50,7 @@ $Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
switch ($Env:DRONE_BUILD_EVENT) {
"pull_request" {
Invoke-Expression "${PSScriptRoot}\clone-pull-reqest.ps1"
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
break
}
"tag" {
@@ -61,4 +61,4 @@ switch ($Env:DRONE_BUILD_EVENT) {
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
break
}
}
}
+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
+126
View File
@@ -0,0 +1,126 @@
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 -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
}
}
`
// 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 merge $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
`