21 Commits

Author SHA1 Message Date
TP Honey 8a0ade0870 Merge pull request #70 from tphoney/use_correct_arm_runner
(fix) use correct arm runner
2023-09-15 16:31:44 +01:00
dependabot-ci 131f624843 (fix) use correct arm runner 2023-09-15 16:01:45 +01:00
TP Honey c92f28d142 Merge pull request #66 from tphoney/harness_move
(maint) move to harness.drone.io
2022-12-07 15:07:44 +00:00
TP Honey 05dd646658 (maint) move to harness.drone.io 2022-12-07 14:32:44 +00:00
Brad Rydzewski b83c004215 add plugin metadata [CI SKIP] 2022-10-03 15:54:33 -04:00
Don 8b44f3c41f Merge pull request #59 from jlehtimaki/master
This fixes false success on kubernetes
2020-08-26 08:11:23 -07:00
Joonas Lehtimäki 5d0c917e8f This fixes false success on kubernetes 2020-08-26 10:27:45 +03:00
Thomas Boerger dc62731f93 Merge pull request #58 from doubles-ss/master
Add support for Authorization type Bearer Token
2020-08-03 08:35:22 +02:00
Suriya.S b2d83444d1 Change token to token_value and add token_type for support other token type 2020-08-02 00:35:29 +07:00
Suriya.S 07a4386c3d Remove go version in go.mod 2020-08-01 11:10:34 +07:00
Suriya.S 739613d9dc Add Bearer token authen 2020-08-01 11:08:30 +07:00
Thomas Boerger 63eabce274 Merge pull request #56 from primait/fix-payload-signature
Fix payload signature flags
2020-07-14 22:23:37 +02:00
Michelangelo a4a3dd85d0 replace underscore with dash 2020-07-14 15:35:30 +02:00
Thomas Boerger 25de318efb Merge pull request #54 from primait/payload-signature
Payload signature
2020-06-29 09:19:27 +02:00
Michelangelo bff3a91abd Use dash instead of underscore 2020-06-28 18:00:01 +02:00
Michelangelo 32f681e175 Customizable signature header name, rename secret to signature_secret 2020-06-24 09:56:38 +02:00
Michelangelo Morrillo 770ffb857e Include signature algorithm in header field
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-21 15:34:57 +02:00
Michelangelo 7f2efea728 remove go version 2020-05-21 14:57:58 +02:00
Michelangelo a76e37dacb add support for signature header 2020-05-21 14:44:30 +02:00
Thomas Boerger b06afe33fc Merge pull request #53 from Jakob-em/master
Added deployTo to build data
2020-01-08 09:18:02 +01:00
Jakob em 79df46e1e2 Added deployTo to build data 2020-01-05 14:59:36 +01:00
10 changed files with 370 additions and 455 deletions
-371
View File
@@ -1,371 +0,0 @@
def main(ctx):
before = testing()
stages = [
linux('amd64'),
linux('arm64'),
linux('arm'),
windows('1903'),
windows('1809'),
]
after = manifest() + gitter()
for b in before:
for s in stages:
s['depends_on'].append(b['name'])
for s in stages:
for a in after:
a['depends_on'].append(s['name'])
return before + stages + after
def testing():
return [{
'kind': 'pipeline',
'type': 'docker',
'name': 'testing',
'platform': {
'os': 'linux',
'arch': 'amd64',
},
'steps': [
{
'name': 'vet',
'image': 'golang:1.12',
'pull': 'always',
'commands': [
'go vet ./...'
],
'volumes': [
{
'name': 'gopath',
'path': '/go'
}
]
},
{
'name': 'test',
'image': 'golang:1.12',
'pull': 'always',
'commands': [
'go test -cover ./...'
],
'volumes': [
{
'name': 'gopath',
'path': '/go'
}
]
}
],
'volumes': [
{
'name': 'gopath',
'temp': {}
}
],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
'refs/pull/**'
]
}
}]
def linux(arch):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'linux-%s' % arch,
'platform': {
'os': 'linux',
'arch': arch,
},
'steps': [
{
'name': 'build-push',
'image': 'golang:1.12',
'pull': 'always',
'environment': {
'CGO_ENABLED': '0'
},
'commands': [
'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/linux/%s/drone-webhook' % arch
],
'when': {
'event': {
'exclude': [
'tag'
]
}
}
},
{
'name': 'build-tag',
'image': 'golang:1.12',
'pull': 'always',
'environment': {
'CGO_ENABLED': '0'
},
'commands': [
'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/linux/%s/drone-webhook' % arch
],
'when': {
'event': [
'tag'
]
}
},
{
'name': 'executable',
'image': 'golang:1.12',
'pull': 'always',
'commands': [
'./release/linux/%s/drone-webhook --help' % arch
]
},
{
'name': 'dryrun',
'image': 'plugins/docker',
'pull': 'always',
'settings': {
'dry_run': True,
'tags': 'linux-%s' % arch,
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
'repo': 'plugins/webhook',
'username': {
'from_secret': 'docker_username'
},
'password': {
'from_secret': 'docker_password'
}
},
'when': {
'event': [
'pull_request'
]
}
},
{
'name': 'publish',
'image': 'plugins/docker',
'pull': 'always',
'settings': {
'auto_tag': True,
'auto_tag_suffix': 'linux-%s' % arch,
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
'repo': 'plugins/webhook',
'username': {
'from_secret': 'docker_username'
},
'password': {
'from_secret': 'docker_password'
}
},
'when': {
'event': {
'exclude': [
'pull_request'
]
}
}
}
],
'depends_on': [],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
'refs/pull/**'
]
}
}
def windows(version):
return {
'kind': 'pipeline',
'type': 'ssh',
'name': 'windows-%s' % 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-push',
'environment': {
'CGO_ENABLED': '0'
},
'commands': [
'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/windows/amd64/drone-webhook.exe',
],
'when': {
'event': {
'exclude': [
'tag'
]
}
}
},
{
'name': 'build-tag',
'environment': {
'CGO_ENABLED': '0'
},
'commands': [
'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/windows/amd64/drone-webhook.exe',
],
'when': {
'event': [
'tag'
]
}
},
{
'name': 'executable',
'commands': [
'./release/windows/amd64/drone-webhook.exe --help',
]
},
{
'name': 'latest',
'environment': {
'USERNAME': {
'from_secret': 'docker_username'
},
'PASSWORD': {
'from_secret': 'docker_password'
},
},
'commands': [
'echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin',
'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/webhook:windows-%s-amd64 .' % (version, version),
'docker run --rm plugins/webhook:windows-%s-amd64 --help' % version,
'docker push plugins/webhook:windows-%s-amd64' % version,
],
'when': {
'ref': [
'refs/heads/master',
]
}
},
{
'name': 'tagged',
'environment': {
'USERNAME': {
'from_secret': 'docker_username'
},
'PASSWORD': {
'from_secret': 'docker_password'
},
},
'commands': [
'echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin',
'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/webhook:${DRONE_TAG##v}-windows-%s-amd64 .' % (version, version),
'docker run --rm plugins/webhook:${DRONE_TAG##v}-windows-%s-amd64 --help' % version,
'docker push plugins/webhook:${DRONE_TAG##v}-windows-%s-amd64' % version,
],
'when': {
'ref': [
'refs/tags/**',
]
}
}
],
'depends_on': [],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**',
]
}
}
def manifest():
return [{
'kind': 'pipeline',
'type': 'docker',
'name': 'manifest',
'steps': [
{
'name': 'manifest',
'image': 'plugins/manifest',
'pull': 'always',
'settings': {
'auto_tag': 'true',
'username': {
'from_secret': 'docker_username'
},
'password': {
'from_secret': 'docker_password'
},
'spec': 'docker/manifest.tmpl',
'ignore_missing': 'true',
},
},
{
'name': 'microbadger',
'image': 'plugins/webhook',
'pull': 'always',
'settings': {
'urls': {
'from_secret': 'microbadger_url'
}
},
}
],
'depends_on': [],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**'
]
}
}]
def gitter():
return [{
'kind': 'pipeline',
'type': 'docker',
'name': 'gitter',
'clone': {
'disable': True
},
'steps': [
{
'name': 'gitter',
'image': 'plugins/gitter',
'pull': 'always',
'settings': {
'webhook': {
'from_secret': 'gitter_webhook'
}
},
},
],
'depends_on': [
'manifest'
],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/**'
],
'status': [
'failure'
]
}
}]
+249 -11
View File
@@ -1,16 +1,254 @@
kind: pipeline
type: vm
name: testing
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: lint
image: golang:1.20
pull: always
commands:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- golangci-lint version
- golangci-lint run
volumes:
- name: gopath
path: "/go"
- name: test
image: golang:1.20
commands:
- go test -cover ./...
volumes:
- name: gopath
path: "/go"
volumes:
- name: gopath
temp: {}
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
{"kind": "pipeline", "type": "docker", "name": "testing", "platform": {"os": "linux", "arch": "amd64"}, "steps": [{"name": "vet", "image": "golang:1.12", "pull": "always", "commands": ["go vet ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}, {"name": "test", "image": "golang:1.12", "pull": "always", "commands": ["go test -cover ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}], "volumes": [{"name": "gopath", "temp": {}}], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
kind: pipeline
type: vm
name: linux-amd64
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: environment
image: golang:1.20
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.20
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/amd64/drone-webhook .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.linux.amd64
repo: plugins/webhook
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: linux-amd64
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
{"kind": "pipeline", "type": "docker", "name": "linux-amd64", "platform": {"os": "linux", "arch": "amd64"}, "steps": [{"name": "build-push", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-webhook"], "when": {"event": {"exclude": ["tag"]}}}, {"name": "build-tag", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-webhook"], "when": {"event": ["tag"]}}, {"name": "executable", "image": "golang:1.12", "pull": "always", "commands": ["./release/linux/amd64/drone-webhook --help"]}, {"name": "dryrun", "image": "plugins/docker", "pull": "always", "settings": {"dry_run": true, "tags": "linux-amd64", "dockerfile": "docker/Dockerfile.linux.amd64", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": ["pull_request"]}}, {"name": "publish", "image": "plugins/docker", "pull": "always", "settings": {"auto_tag": true, "auto_tag_suffix": "linux-amd64", "dockerfile": "docker/Dockerfile.linux.amd64", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": {"exclude": ["pull_request"]}}}], "depends_on": ["testing"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
kind: pipeline
type: vm
name: linux-arm64
platform:
os: linux
arch: arm64
pool:
use: ubuntu_arm64
steps:
- name: environment
image: golang:1.20
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.20
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/arm64/drone-webhook .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.linux.arm64
repo: plugins/webhook
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: linux-arm64
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
{"kind": "pipeline", "type": "docker", "name": "linux-arm64", "platform": {"os": "linux", "arch": "arm64"}, "steps": [{"name": "build-push", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-webhook"], "when": {"event": {"exclude": ["tag"]}}}, {"name": "build-tag", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-webhook"], "when": {"event": ["tag"]}}, {"name": "executable", "image": "golang:1.12", "pull": "always", "commands": ["./release/linux/arm64/drone-webhook --help"]}, {"name": "dryrun", "image": "plugins/docker", "pull": "always", "settings": {"dry_run": true, "tags": "linux-arm64", "dockerfile": "docker/Dockerfile.linux.arm64", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": ["pull_request"]}}, {"name": "publish", "image": "plugins/docker", "pull": "always", "settings": {"auto_tag": true, "auto_tag_suffix": "linux-arm64", "dockerfile": "docker/Dockerfile.linux.arm64", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": {"exclude": ["pull_request"]}}}], "depends_on": ["testing"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
kind: pipeline
type: vm
name: windows-1809
platform:
os: windows
arch: amd64
pool:
use: windows
steps:
- name: environment
image: golang:1.20
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.20
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/drone-webhook.exe .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.windows.1809
repo: plugins/webhook
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-1809-amd64
daemon_off: true
purge: false
when:
ref:
- refs/heads/master
- refs/tags/**
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
{"kind": "pipeline", "type": "docker", "name": "linux-arm", "platform": {"os": "linux", "arch": "arm"}, "steps": [{"name": "build-push", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-webhook"], "when": {"event": {"exclude": ["tag"]}}}, {"name": "build-tag", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-webhook"], "when": {"event": ["tag"]}}, {"name": "executable", "image": "golang:1.12", "pull": "always", "commands": ["./release/linux/arm/drone-webhook --help"]}, {"name": "dryrun", "image": "plugins/docker", "pull": "always", "settings": {"dry_run": true, "tags": "linux-arm", "dockerfile": "docker/Dockerfile.linux.arm", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": ["pull_request"]}}, {"name": "publish", "image": "plugins/docker", "pull": "always", "settings": {"auto_tag": true, "auto_tag_suffix": "linux-arm", "dockerfile": "docker/Dockerfile.linux.arm", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": {"exclude": ["pull_request"]}}}], "depends_on": ["testing"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
kind: pipeline
type: vm
name: windows-ltsc2022
platform:
os: windows
arch: amd64
pool:
use: windows-2022
steps:
- name: environment
image: golang:1.20
pull: always
environment:
CGO_ENABLED: "0"
commands:
- go version
- go env
- name: build
image: golang:1.20
environment:
CGO_ENABLED: "0"
commands:
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/drone-webhook.exe .
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.windows.ltsc2022
repo: plugins/webhook
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-ltsc2022-amd64
daemon_off: true
purge: false
when:
ref:
- refs/heads/master
- refs/tags/**
depends_on:
- testing
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
---
{"kind": "pipeline", "type": "ssh", "name": "windows-1903", "platform": {"os": "windows"}, "server": {"host": {"from_secret": "windows_server_1903"}, "user": {"from_secret": "windows_username"}, "password": {"from_secret": "windows_password"}}, "steps": [{"name": "build-push", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"], "when": {"event": {"exclude": ["tag"]}}}, {"name": "build-tag", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"], "when": {"event": ["tag"]}}, {"name": "executable", "commands": ["./release/windows/amd64/drone-webhook.exe --help"]}, {"name": "latest", "environment": {"USERNAME": {"from_secret": "docker_username"}, "PASSWORD": {"from_secret": "docker_password"}}, "commands": ["echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin", "docker build --pull -f docker/Dockerfile.windows.1903 -t plugins/webhook:windows-1903-amd64 .", "docker run --rm plugins/webhook:windows-1903-amd64 --help", "docker push plugins/webhook:windows-1903-amd64"], "when": {"ref": ["refs/heads/master"]}}, {"name": "tagged", "environment": {"USERNAME": {"from_secret": "docker_username"}, "PASSWORD": {"from_secret": "docker_password"}}, "commands": ["echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin", "docker build --pull -f docker/Dockerfile.windows.1903 -t plugins/webhook:${DRONE_TAG##v}-windows-1903-amd64 .", "docker run --rm plugins/webhook:${DRONE_TAG##v}-windows-1903-amd64 --help", "docker push plugins/webhook:${DRONE_TAG##v}-windows-1903-amd64"], "when": {"ref": ["refs/tags/**"]}}], "depends_on": ["testing"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**"]}}
---
{"kind": "pipeline", "type": "ssh", "name": "windows-1809", "platform": {"os": "windows"}, "server": {"host": {"from_secret": "windows_server_1809"}, "user": {"from_secret": "windows_username"}, "password": {"from_secret": "windows_password"}}, "steps": [{"name": "build-push", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"], "when": {"event": {"exclude": ["tag"]}}}, {"name": "build-tag", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"], "when": {"event": ["tag"]}}, {"name": "executable", "commands": ["./release/windows/amd64/drone-webhook.exe --help"]}, {"name": "latest", "environment": {"USERNAME": {"from_secret": "docker_username"}, "PASSWORD": {"from_secret": "docker_password"}}, "commands": ["echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin", "docker build --pull -f docker/Dockerfile.windows.1809 -t plugins/webhook:windows-1809-amd64 .", "docker run --rm plugins/webhook:windows-1809-amd64 --help", "docker push plugins/webhook:windows-1809-amd64"], "when": {"ref": ["refs/heads/master"]}}, {"name": "tagged", "environment": {"USERNAME": {"from_secret": "docker_username"}, "PASSWORD": {"from_secret": "docker_password"}}, "commands": ["echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin", "docker build --pull -f docker/Dockerfile.windows.1809 -t plugins/webhook:${DRONE_TAG##v}-windows-1809-amd64 .", "docker run --rm plugins/webhook:${DRONE_TAG##v}-windows-1809-amd64 --help", "docker push plugins/webhook:${DRONE_TAG##v}-windows-1809-amd64"], "when": {"ref": ["refs/tags/**"]}}], "depends_on": ["testing"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**"]}}
---
{"kind": "pipeline", "type": "docker", "name": "manifest", "steps": [{"name": "manifest", "image": "plugins/manifest", "pull": "always", "settings": {"auto_tag": "true", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}, "spec": "docker/manifest.tmpl", "ignore_missing": "true"}}, {"name": "microbadger", "image": "plugins/webhook", "pull": "always", "settings": {"urls": {"from_secret": "microbadger_url"}}}], "depends_on": ["linux-amd64", "linux-arm64", "linux-arm", "windows-1903", "windows-1809"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**"]}}
---
{"kind": "pipeline", "type": "docker", "name": "gitter", "clone": {"disable": true}, "steps": [{"name": "gitter", "image": "plugins/gitter", "pull": "always", "settings": {"webhook": {"from_secret": "gitter_webhook"}}}], "depends_on": ["manifest", "linux-amd64", "linux-arm64", "linux-arm", "windows-1903", "windows-1809"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**"], "status": ["failure"]}}
kind: pipeline
type: vm
name: manifest
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: manifest
image: plugins/manifest
settings:
auto_tag: "true"
username:
from_secret: docker_username
password:
from_secret: docker_password
spec: docker/manifest.tmpl
ignore_missing: true
depends_on:
- linux-amd64
- linux-arm64
- windows-1809
- windows-ltsc2022
trigger:
ref:
- refs/heads/master
- refs/tags/**
-9
View File
@@ -1,9 +0,0 @@
FROM plugins/base:multiarch
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.name="Drone Webhook" \
org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0"
ADD release/linux/arm/drone-webhook /bin/
ENTRYPOINT ["/bin/drone-webhook"]
@@ -1,5 +1,5 @@
# escape=`
FROM plugins/base:windows-1903-amd64
FROM plugins/base:windows-ltsc2022-amd64@sha256:0f90d5bceb432f1ee6f93cf44eed6a38c322834edd55df8a6648c9e6f15131f4
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Webhook" `
+2 -6
View File
@@ -14,17 +14,13 @@ manifests:
platform:
architecture: arm64
os: linux
- image: plugins/webhook:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
- image: plugins/webhook:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows
version: 1809
- image: plugins/webhook:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
- image: plugins/webhook:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
platform:
architecture: amd64
os: windows
version: 1903
version: ltsc2022
+8 -3
View File
@@ -1,12 +1,17 @@
module github.com/drone-plugins/drone-webhook
require (
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594
github.com/joho/godotenv v1.3.0
github.com/urfave/cli v1.20.0
)
require (
bou.ke/monkey v1.0.1 // indirect
github.com/aymerick/raymond v2.0.2+incompatible // indirect
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594
github.com/pkg/errors v0.8.1 // indirect
github.com/stretchr/testify v1.3.0 // indirect
github.com/tkuchiki/faketime v0.1.1 // indirect
github.com/urfave/cli v1.20.0
gopkg.in/yaml.v2 v2.2.2 // indirect
)
go 1.20
+2 -8
View File
@@ -2,22 +2,16 @@ bou.ke/monkey v1.0.1 h1:zEMLInw9xvNakzUUPjfS4Ds6jYPqCFx3m7bRmG5NH2U=
bou.ke/monkey v1.0.1/go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg=
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594 h1:zPRVfiHpXeGt1XGpK2TQcaj2lRydiGdVz1AoHkaC554=
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594/go.mod h1:u34woe41m58Whrf21iH6z/xLOIRM3650LhWAyUc7Oik=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tkuchiki/faketime v0.1.1 h1:UZjBlktFAi23wo+jWuHuNoHUpLnB0j/5B62bl5nCPls=
github.com/tkuchiki/faketime v0.1.1/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+59 -22
View File
@@ -4,6 +4,7 @@ import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/urfave/cli"
)
@@ -34,6 +35,17 @@ func main() {
Usage: "password for basic auth",
EnvVar: "PLUGIN_PASSWORD,WEBHOOK_PASSWORD",
},
cli.StringFlag{
Name: "token-value",
Usage: "token value",
EnvVar: "PLUGIN_TOKEN_VALUE,WEBHOOK_TOKEN_VALUE",
},
cli.StringFlag{
Name: "token-type",
Usage: "type of token",
EnvVar: "PLUGIN_TOKEN_TYPE,WEBHOOK_TOKEN_TYPE",
Value: "Bearer",
},
cli.StringFlag{
Name: "content-type",
Usage: "content type",
@@ -70,6 +82,17 @@ func main() {
Usage: "skip ssl verification",
EnvVar: "PLUGIN_SKIP_VERIFY",
},
cli.StringFlag{
Name: "signature-header",
Usage: "header name to use in request",
EnvVar: "PLUGIN_SIGNATURE_HEADER,WEBHOOK_SIGNATURE_HEADER",
Value: "X-Drone-Signature",
},
cli.StringFlag{
Name: "signature-secret",
Usage: "secret to generate signature",
EnvVar: "PLUGIN_SIGNATURE_SECRET,WEBHOOK_SIGNATURE_SECRET",
},
cli.StringFlag{
Name: "repo.owner",
Usage: "repository owner",
@@ -129,6 +152,11 @@ func main() {
Usage: "build link",
EnvVar: "DRONE_BUILD_LINK",
},
cli.StringFlag{
Name: "build.deployTo",
Usage: "environment deployed to",
EnvVar: "DRONE_DEPLOY_TO",
},
cli.Int64Flag{
Name: "build.started",
Usage: "build started",
@@ -151,6 +179,10 @@ func main() {
},
}
if _, err := os.Stat("/run/drone/env"); err == nil {
_ = godotenv.Overload("/run/drone/env")
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
@@ -163,33 +195,38 @@ func run(c *cli.Context) error {
Name: c.String("repo.name"),
},
Build: Build{
Tag: c.String("build.tag"),
Number: c.Int("build.number"),
Event: c.String("build.event"),
Status: c.String("build.status"),
Commit: c.String("commit.sha"),
Ref: c.String("commit.ref"),
Branch: c.String("commit.branch"),
Author: c.String("commit.author"),
Message: c.String("commit.message"),
Link: c.String("build.link"),
Started: c.Int64("build.started"),
Created: c.Int64("build.created"),
Tag: c.String("build.tag"),
Number: c.Int("build.number"),
Event: c.String("build.event"),
Status: c.String("build.status"),
Commit: c.String("commit.sha"),
Ref: c.String("commit.ref"),
Branch: c.String("commit.branch"),
Author: c.String("commit.author"),
Message: c.String("commit.message"),
Link: c.String("build.link"),
DeployTo: c.String("build.deployTo"),
Started: c.Int64("build.started"),
Created: c.Int64("build.created"),
},
Job: Job{
Started: c.Int64("job.started"),
},
Config: Config{
Method: c.String("method"),
Username: c.String("username"),
Password: c.String("password"),
ContentType: c.String("content-type"),
Template: c.String("template"),
Headers: c.StringSlice("headers"),
URLs: c.StringSlice("urls"),
ValidCodes: c.IntSlice("valid-response-codes"),
Debug: c.Bool("debug"),
SkipVerify: c.Bool("skip-verify"),
Method: c.String("method"),
Username: c.String("username"),
Password: c.String("password"),
TokenValue: c.String("token-value"),
TokenType: c.String("token-type"),
ContentType: c.String("content-type"),
Template: c.String("template"),
Headers: c.StringSlice("headers"),
URLs: c.StringSlice("urls"),
ValidCodes: c.IntSlice("valid-response-codes"),
Debug: c.Bool("debug"),
SkipVerify: c.Bool("skip-verify"),
SignatureHeader: c.String("signature-header"),
SignatureSecret: c.String("signature-secret"),
},
}
+46 -24
View File
@@ -2,10 +2,13 @@ package main
import (
"bytes"
"crypto/hmac"
"crypto/sha256"
"crypto/tls"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
@@ -21,31 +24,36 @@ type (
}
Build struct {
Tag string `json:"tag"`
Event string `json:"event"`
Number int `json:"number"`
Commit string `json:"commit"`
Ref string `json:"ref"`
Branch string `json:"branch"`
Author string `json:"author"`
Message string `json:"message"`
Status string `json:"status"`
Link string `json:"link"`
Started int64 `json:"started"`
Created int64 `json:"created"`
Tag string `json:"tag"`
Event string `json:"event"`
Number int `json:"number"`
Commit string `json:"commit"`
Ref string `json:"ref"`
Branch string `json:"branch"`
Author string `json:"author"`
Message string `json:"message"`
Status string `json:"status"`
Link string `json:"link"`
DeployTo string `json:"deployTo"`
Started int64 `json:"started"`
Created int64 `json:"created"`
}
Config struct {
Method string
Username string
Password string
ContentType string
Template string
Headers []string
URLs []string
ValidCodes []int
Debug bool
SkipVerify bool
Method string
Username string
Password string
TokenValue string
TokenType string
ContentType string
Template string
Headers []string
URLs []string
ValidCodes []int
Debug bool
SkipVerify bool
SignatureHeader string
SignatureSecret string
}
Job struct {
@@ -116,6 +124,16 @@ func (p Plugin) Exec() error {
req.Header.Set("Content-Type", p.Config.ContentType)
if p.Config.SignatureSecret != "" {
// generate signature with secret and body
h := hmac.New(sha256.New, []byte(p.Config.SignatureSecret))
h.Write(b)
sha := hex.EncodeToString(h.Sum(nil))
// append signature to headers
req.Header.Set(p.Config.SignatureHeader, fmt.Sprintf("sha256=%s", sha))
}
for _, value := range p.Config.Headers {
header := strings.Split(value, "=")
req.Header.Set(header[0], header[1])
@@ -125,6 +143,10 @@ func (p Plugin) Exec() error {
req.SetBasicAuth(p.Config.Username, p.Config.Password)
}
if p.Config.TokenValue != "" {
req.Header.Set("Authorization", fmt.Sprintf("%s %s", p.Config.TokenType, p.Config.TokenValue))
}
client := http.DefaultClient
if p.Config.SkipVerify {
@@ -147,7 +169,7 @@ func (p Plugin) Exec() error {
defer resp.Body.Close()
if p.Config.Debug || resp.StatusCode >= http.StatusBadRequest {
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error: Failed to read the HTTP response body. %s\n", err)
+3
View File
@@ -0,0 +1,3 @@
run:
go:
module: github.com/drone-plugins/drone-webhook