mirror of
https://github.com/drone-plugins/drone-webhook.git
synced 2026-06-04 18:24:05 +08:00
Compare commits
21 Commits
refactoring
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a0ade0870 | |||
| 131f624843 | |||
| c92f28d142 | |||
| 05dd646658 | |||
| b83c004215 | |||
| 8b44f3c41f | |||
| 5d0c917e8f | |||
| dc62731f93 | |||
| b2d83444d1 | |||
| 07a4386c3d | |||
| 739613d9dc | |||
| 63eabce274 | |||
| a4a3dd85d0 | |||
| 25de318efb | |||
| bff3a91abd | |||
| 32f681e175 | |||
| 770ffb857e | |||
| 7f2efea728 | |||
| a76e37dacb | |||
| b06afe33fc | |||
| 79df46e1e2 |
-371
@@ -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
@@ -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: vm
|
||||||
{"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/**"]}}
|
name: manifest
|
||||||
---
|
platform:
|
||||||
{"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/**"]}}
|
os: linux
|
||||||
---
|
arch: amd64
|
||||||
{"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"]}}
|
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/**
|
||||||
|
|||||||
@@ -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=`
|
# escape=`
|
||||||
FROM plugins/base:windows-1903-amd64
|
FROM plugins/base:windows-ltsc2022-amd64@sha256:0f90d5bceb432f1ee6f93cf44eed6a38c322834edd55df8a6648c9e6f15131f4
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||||
org.label-schema.name="Drone Webhook" `
|
org.label-schema.name="Drone Webhook" `
|
||||||
@@ -14,17 +14,13 @@ manifests:
|
|||||||
platform:
|
platform:
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
os: linux
|
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
|
- image: plugins/webhook:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1809
|
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:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: windows
|
os: windows
|
||||||
version: 1903
|
version: ltsc2022
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
module github.com/drone-plugins/drone-webhook
|
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 (
|
require (
|
||||||
bou.ke/monkey v1.0.1 // indirect
|
bou.ke/monkey v1.0.1 // indirect
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible // 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/pkg/errors v0.8.1 // indirect
|
||||||
github.com/stretchr/testify v1.3.0 // indirect
|
|
||||||
github.com/tkuchiki/faketime v0.1.1 // indirect
|
github.com/tkuchiki/faketime v0.1.1 // indirect
|
||||||
github.com/urfave/cli v1.20.0
|
|
||||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
gopkg.in/yaml.v2 v2.2.2 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|||||||
@@ -2,22 +2,16 @@ bou.ke/monkey v1.0.1 h1:zEMLInw9xvNakzUUPjfS4Ds6jYPqCFx3m7bRmG5NH2U=
|
|||||||
bou.ke/monkey v1.0.1/go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg=
|
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 h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
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 h1:zPRVfiHpXeGt1XGpK2TQcaj2lRydiGdVz1AoHkaC554=
|
||||||
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594/go.mod h1:u34woe41m58Whrf21iH6z/xLOIRM3650LhWAyUc7Oik=
|
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 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
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 h1:UZjBlktFAi23wo+jWuHuNoHUpLnB0j/5B62bl5nCPls=
|
||||||
github.com/tkuchiki/faketime v0.1.1/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
|
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 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
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/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 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,6 +35,17 @@ func main() {
|
|||||||
Usage: "password for basic auth",
|
Usage: "password for basic auth",
|
||||||
EnvVar: "PLUGIN_PASSWORD,WEBHOOK_PASSWORD",
|
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{
|
cli.StringFlag{
|
||||||
Name: "content-type",
|
Name: "content-type",
|
||||||
Usage: "content type",
|
Usage: "content type",
|
||||||
@@ -70,6 +82,17 @@ func main() {
|
|||||||
Usage: "skip ssl verification",
|
Usage: "skip ssl verification",
|
||||||
EnvVar: "PLUGIN_SKIP_VERIFY",
|
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{
|
cli.StringFlag{
|
||||||
Name: "repo.owner",
|
Name: "repo.owner",
|
||||||
Usage: "repository owner",
|
Usage: "repository owner",
|
||||||
@@ -129,6 +152,11 @@ func main() {
|
|||||||
Usage: "build link",
|
Usage: "build link",
|
||||||
EnvVar: "DRONE_BUILD_LINK",
|
EnvVar: "DRONE_BUILD_LINK",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "build.deployTo",
|
||||||
|
Usage: "environment deployed to",
|
||||||
|
EnvVar: "DRONE_DEPLOY_TO",
|
||||||
|
},
|
||||||
cli.Int64Flag{
|
cli.Int64Flag{
|
||||||
Name: "build.started",
|
Name: "build.started",
|
||||||
Usage: "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 {
|
if err := app.Run(os.Args); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -163,33 +195,38 @@ func run(c *cli.Context) error {
|
|||||||
Name: c.String("repo.name"),
|
Name: c.String("repo.name"),
|
||||||
},
|
},
|
||||||
Build: Build{
|
Build: Build{
|
||||||
Tag: c.String("build.tag"),
|
Tag: c.String("build.tag"),
|
||||||
Number: c.Int("build.number"),
|
Number: c.Int("build.number"),
|
||||||
Event: c.String("build.event"),
|
Event: c.String("build.event"),
|
||||||
Status: c.String("build.status"),
|
Status: c.String("build.status"),
|
||||||
Commit: c.String("commit.sha"),
|
Commit: c.String("commit.sha"),
|
||||||
Ref: c.String("commit.ref"),
|
Ref: c.String("commit.ref"),
|
||||||
Branch: c.String("commit.branch"),
|
Branch: c.String("commit.branch"),
|
||||||
Author: c.String("commit.author"),
|
Author: c.String("commit.author"),
|
||||||
Message: c.String("commit.message"),
|
Message: c.String("commit.message"),
|
||||||
Link: c.String("build.link"),
|
Link: c.String("build.link"),
|
||||||
Started: c.Int64("build.started"),
|
DeployTo: c.String("build.deployTo"),
|
||||||
Created: c.Int64("build.created"),
|
Started: c.Int64("build.started"),
|
||||||
|
Created: c.Int64("build.created"),
|
||||||
},
|
},
|
||||||
Job: Job{
|
Job: Job{
|
||||||
Started: c.Int64("job.started"),
|
Started: c.Int64("job.started"),
|
||||||
},
|
},
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Method: c.String("method"),
|
Method: c.String("method"),
|
||||||
Username: c.String("username"),
|
Username: c.String("username"),
|
||||||
Password: c.String("password"),
|
Password: c.String("password"),
|
||||||
ContentType: c.String("content-type"),
|
TokenValue: c.String("token-value"),
|
||||||
Template: c.String("template"),
|
TokenType: c.String("token-type"),
|
||||||
Headers: c.StringSlice("headers"),
|
ContentType: c.String("content-type"),
|
||||||
URLs: c.StringSlice("urls"),
|
Template: c.String("template"),
|
||||||
ValidCodes: c.IntSlice("valid-response-codes"),
|
Headers: c.StringSlice("headers"),
|
||||||
Debug: c.Bool("debug"),
|
URLs: c.StringSlice("urls"),
|
||||||
SkipVerify: c.Bool("skip-verify"),
|
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"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/sha256"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -21,31 +24,36 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Build struct {
|
Build struct {
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Number int `json:"number"`
|
Number int `json:"number"`
|
||||||
Commit string `json:"commit"`
|
Commit string `json:"commit"`
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
Branch string `json:"branch"`
|
Branch string `json:"branch"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
Started int64 `json:"started"`
|
DeployTo string `json:"deployTo"`
|
||||||
Created int64 `json:"created"`
|
Started int64 `json:"started"`
|
||||||
|
Created int64 `json:"created"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Config struct {
|
Config struct {
|
||||||
Method string
|
Method string
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
ContentType string
|
TokenValue string
|
||||||
Template string
|
TokenType string
|
||||||
Headers []string
|
ContentType string
|
||||||
URLs []string
|
Template string
|
||||||
ValidCodes []int
|
Headers []string
|
||||||
Debug bool
|
URLs []string
|
||||||
SkipVerify bool
|
ValidCodes []int
|
||||||
|
Debug bool
|
||||||
|
SkipVerify bool
|
||||||
|
SignatureHeader string
|
||||||
|
SignatureSecret string
|
||||||
}
|
}
|
||||||
|
|
||||||
Job struct {
|
Job struct {
|
||||||
@@ -116,6 +124,16 @@ func (p Plugin) Exec() error {
|
|||||||
|
|
||||||
req.Header.Set("Content-Type", p.Config.ContentType)
|
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 {
|
for _, value := range p.Config.Headers {
|
||||||
header := strings.Split(value, "=")
|
header := strings.Split(value, "=")
|
||||||
req.Header.Set(header[0], header[1])
|
req.Header.Set(header[0], header[1])
|
||||||
@@ -125,6 +143,10 @@ func (p Plugin) Exec() error {
|
|||||||
req.SetBasicAuth(p.Config.Username, p.Config.Password)
|
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
|
client := http.DefaultClient
|
||||||
|
|
||||||
if p.Config.SkipVerify {
|
if p.Config.SkipVerify {
|
||||||
@@ -147,7 +169,7 @@ func (p Plugin) Exec() error {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if p.Config.Debug || resp.StatusCode >= http.StatusBadRequest {
|
if p.Config.Debug || resp.StatusCode >= http.StatusBadRequest {
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error: Failed to read the HTTP response body. %s\n", err)
|
fmt.Printf("Error: Failed to read the HTTP response body. %s\n", err)
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
run:
|
||||||
|
go:
|
||||||
|
module: github.com/drone-plugins/drone-webhook
|
||||||
Reference in New Issue
Block a user