Unification: Drone config, Makefile, structure and badges

This commit is contained in:
Thomas Boerger 2016-01-18 22:33:14 +01:00 committed by Thomas Boerger
parent c5893badeb
commit e1296c5499
5 changed files with 98 additions and 59 deletions

View File

@ -1 +1 @@
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.ZcFjZ8jiWlv1tNJ4QqUq9bALGfUv_GXycqDUvctUZyCGAcbIov3LMFFBNH8kOHQucwAy3sjSt8ECpcLw8qVw3S7OH-JoppqIXG6bAXld5djqyCoXl9tB8t1XhdkuFDN0utQ7fVBn72rcL9p9YdF0WfI36UJwIpCXpaFgo5OW6-a-Ko0AWlCKm8Ju4GII9RR57WAJqOiVV2feyuFVntnXcd08iFkOX9Bx85ybzR6RutyoRmptVcgalejzUIFrNDWztCXqdhtO8Nwo9QRBR0lADazWuY30mMw8Y9pP3JIvngIxh4gnuJ_33ISZg3Jwvg2s3M7YTBJFF5Z_A3ThupQ2fw.zu6cKI3vHnuQBcHw.NTh_lLkmnft9dDtZtcAqzzk1HzhIQBdlSu5IaNMhI0_9UNgg2QQeGORv_MPeKhgIghbKi1YHTPmanTXezOHAzfLZYhFitDAsYKTr8w6IM7gAEqTFSBDlDC-kEFwUnTXyKYgsY_nWvIOnkCKdaFyx3APDrQBWvwBmOhyJNxbhkAR4IG0o9ZEl9d9CJUw5zaOwwtLruxbUCsnfXKJhhjVk3HxW6cwjxXfn5rAn2RdT.BRec67CF9JHLervCrGwQfw
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.RIc8LP2tvwcxilJVzcK9VpGvg49hVFn1WVW5TOXO2ynLB4Ny3o4I2d3DdJIvZ1sUc9g7DWI4ibQS8fVOKBMnvmPu-b0mQzxCQlsUviJDmq2i7_z4ajQ-AKYok40aIWZRAxP76B4TxreE2iVCE_y2UsVChQOiRo9NmqQlpxqgzS8XH2LpXnsNpN5DFOMLAETsPH6qJzENXxRUgW3V8tTXyJIpOO2ks5cpyZp4tqlGF2Hoilhy3quOQ73suoqPqvOcnLydZCwBSAOg6E1ei9XTQfC0Mgxo1jEGH6mhtYoBQdLs075S4gwthXUp10EUOOOCWeT9ydZu8nDUFcdedBhBGw.068KASoq_91EWfuX._RI3btAHFVMyCd2p82UK6W3vW9ppuJd8mtRoB94S4y6s6AoBCrCcE4JJQINhjLHj-LOeB0AqgZMkLjyOEKb7fp0VDZ2G6btWrFwr2naYC7eYsC1i_bZ3N3Vs_e7pdTPkluxd7FqbXNKvPT34Fynsj4xchb3kedvhC1wpkhbNoWw-K9MNUKovk-goKnLdZX4jCafkpdkD3lZZEVAtjXMkOs2s4UqGtPdmE1WF8eAkQJe_wTaikZAWvFL40t61bCIUK9k8eYhgRXh8h7FEC3xmEkQDP1PytlHLiIvryTauh3BKTS-zzFTvOBEtPd2NqEWO_gLNkk-JyGDBCJ7WKM3VPjhv-Lz9awAGKA9jcNvOgHSTEt_fuLoeMVCykyB7zsfdgiSyc1gG5DLjOkyB7g5TwJe-j0CG0mfLyLOa8t7EITE.6zXxy0JE3-1bp5q2G7oY9A

View File

@ -7,13 +7,25 @@ build:
- make test
publish:
coverage:
when:
branch: master
docker:
username: $$DOCKER_USER
password: $$DOCKER_PASS
email: $$DOCKER_EMAIL
repo: plugins/drone-webhook
tag: latest
when:
branch: master
docker:
username: $$DOCKER_USER
password: $$DOCKER_PASS
email: $$DOCKER_EMAIL
repo: plugins/drone-webhook
tag: develop
when:
branch: develop
plugin:
name: Webhook

View File

@ -1,13 +1,11 @@
.PHONY: clean deps test build docker
export GOOS ?= linux
export GOARCH ?= amd64
export CGO_ENABLED ?= 0
.PHONY: clean deps fmt vet test docker
EXECUTABLE ?= drone-webhook
IMAGE ?= plugins/$(EXECUTABLE)
CI_BUILD_NUMBER ?= 0
LDFLAGS += -X "main.buildDate=$(shell date -u '+%Y-%m-%d %H:%M:%S %Z')"
LDFLAGS += -X "main.build=$(CI_BUILD_NUMBER)"
LDFLAGS = -X "main.buildDate=$(shell date -u '+%Y-%m-%d %H:%M:%S %Z')"
PACKAGES = $(shell go list ./... | grep -v /vendor/)
clean:
go clean -i ./...
@ -15,17 +13,20 @@ clean:
deps:
go get -t ./...
test:
go test -cover ./...
fmt:
go fmt ./...
go fmt $(PACKAGES)
vet:
go vet ./...
go vet $(PACKAGES)
build:
go build -ldflags '-s -w $(LDFLAGS)'
test:
@for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
docker:
docker build --rm=true -t plugins/drone-webhook .
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-s -w $(LDFLAGS)'
docker build --rm -t $(IMAGE) .
$(EXECUTABLE): $(wildcard *.go)
go build -ldflags '-s -w $(LDFLAGS)'
build: $(EXECUTABLE)

111
README.md
View File

@ -1,44 +1,62 @@
# drone-webhook
[![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-webhook/status.svg)](http://beta.drone.io/drone-plugins/drone-webhook)
[![Coverage Status](https://aircover.co/badges/drone-plugins/drone-webhook/coverage.svg)](https://aircover.co/drone-plugins/drone-webhook)
[![](https://badge.imagelayers.io/plugins/drone-webhook:latest.svg)](https://imagelayers.io/?images=plugins/drone-webhook:latest 'Get your own badge on imagelayers.io')
Drone plugin for sending notifications via Webhook
Drone plugin to send build status notifications via Webhook
## Usage
## Binary
Build the binary using `make`:
```
make deps build
```
### Example
```sh
./drone-webhook <<EOF
{
"repo" : {
"owner": "foo",
"name": "bar",
"full_name": "foo/bar"
"repo": {
"clone_url": "git://github.com/drone/drone",
"owner": "drone",
"name": "dron",
"full_name": "drone/drone"
},
"build" : {
"system": {
"link_url": "https://beta.drone.io"
},
"build": {
"number": 22,
"status": "success",
"started_at": 1421029603,
"finished_at": 1421029813,
"commit": "9f2849d5",
"branch": "master",
"message": "Update the Readme",
"author": "johnsmith",
"author_email": "john.smith@gmail.com"
"event": "push",
"branch": "master",
"commit": "436b7a6e2abaddfd35740527353e78a227ddcb2c",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/github.com/drone/drone"
},
"vargs": {
"urls": ["https://your.webhook/..."],
"debug": true,
"auth": {
"username": "johnsmith",
"password": "secretPass"
},
"headers": {
"SomeHeader": "SomeHeaderValue"
},
"method": "POST",
"template": "{\"git_branch\": \"{{ .Build.Branch }}\"}",
"content_type": "application/json"
"urls": [
"https://your.webhook/..."
],
"debug": true,
"auth": {
"username": "johnsmith",
"password": "secretPass"
},
"method": "POST",
"template": "{\"git_branch\": \"{{ .Build.Branch }}\"}",
"content_type": "application/json"
}
}
EOF
@ -46,10 +64,10 @@ EOF
## Docker
Build the Docker container using `make`:
Build the container using `make`:
```
make deps build docker
make deps docker
```
### Example
@ -57,35 +75,44 @@ make deps build docker
```sh
docker run -i plugins/drone-webhook <<EOF
{
"repo" : {
"owner": "foo",
"name": "bar",
"full_name": "foo/bar"
"repo": {
"clone_url": "git://github.com/drone/drone",
"owner": "drone",
"name": "dron",
"full_name": "drone/drone"
},
"build" : {
"system": {
"link_url": "https://beta.drone.io"
},
"build": {
"number": 22,
"status": "success",
"started_at": 1421029603,
"finished_at": 1421029813,
"commit": "9f2849d5",
"branch": "master",
"message": "Update the Readme",
"author": "johnsmith",
"author_email": "john.smith@gmail.com"
"event": "push",
"branch": "master",
"commit": "436b7a6e2abaddfd35740527353e78a227ddcb2c",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/github.com/drone/drone"
},
"vargs": {
"urls": ["https://your.webhook/..."],
"debug": true,
"auth": {
"username": "johnsmith",
"password": "secretPass"
},
"headers": {
"SomeHeader": "SomeHeaderValue"
},
"method": "POST",
"template": "{\"git_branch\": \"{{ .Build.Branch }}\"}",
"content_type": "application/json"
"urls": [
"https://your.webhook/..."
],
"debug": true,
"auth": {
"username": "johnsmith",
"password": "secretPass"
},
"method": "POST",
"template": "{\"git_branch\": \"{{ .Build.Branch }}\"}",
"content_type": "application/json"
}
}
EOF

View File

@ -20,7 +20,6 @@ const (
)
var (
build string
buildDate string
)