Compare commits
1
Commits
0.1.0
..
1ed5d2c1d6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ed5d2c1d6 |
+1
-7
@@ -1,15 +1,9 @@
|
||||
pipeline:
|
||||
|
||||
test:
|
||||
image: alpine
|
||||
commands:
|
||||
- cd test
|
||||
- ./sendxmpp_parameter_test.sh
|
||||
|
||||
docker:
|
||||
image: plugins/docker
|
||||
repo: bunix42/drone-sendxmpp
|
||||
tags:
|
||||
- 0.1.0
|
||||
- 0.0.1
|
||||
- latest
|
||||
secrets: [ docker_username, docker_password ]
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
FROM debian:9-slim
|
||||
FROM debian
|
||||
|
||||
LABEL maintainer="hanjo@bunix.de"
|
||||
MAINTAINER hanjo@bunix.de
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
sendxmpp \
|
||||
|
||||
@@ -1,60 +1,2 @@
|
||||
# drone-sendxmpp
|
||||
|
||||
Drone plugin for sending messages to Jabber accounts, using [sendxmpp](http://sendxmpp.hostname.sk/)
|
||||
|
||||

|
||||
[](https://microbadger.com/images/bunix42/drone-sendxmpp "Get your own version badge on microbadger.com")
|
||||
[](https://microbadger.com/images/bunix42/drone-sendxmpp "Get your own image badge on microbadger.com")
|
||||
[](https://hub.docker.com/r/bunix42/drone-sendxmpp/)
|
||||
|
||||
# Usage
|
||||
|
||||
## prerequisites
|
||||
|
||||
you obviously need a valid jabber account to send messages, this can be your own account or a dedicated one just for your drone notifications.
|
||||
|
||||
## standalone using docker
|
||||
|
||||
```
|
||||
docker run
|
||||
-e PLUGIN_USERNAME=someaccount
|
||||
-e PLUGIN_JSERVER=jabberserver.invalid
|
||||
-e SENDXMPP_PASSWORD=secret1234
|
||||
-e PLUGIN_RECIPIENT=someone@jabberserver.invalid
|
||||
bunix42/drone-sendxmpp
|
||||
```
|
||||
|
||||
## drone pipeline
|
||||
|
||||
```
|
||||
pipeline:
|
||||
sendxmpp:
|
||||
image: bunix42/drone-sendxmpp
|
||||
pull: true
|
||||
recipient: someone@jabberserver.invalid
|
||||
jserver: jabberserver.invalid
|
||||
secrets: [ sendxmpp_username, sendxmpp_password ]
|
||||
```
|
||||
|
||||
### secret reference
|
||||
|
||||
* `sendxmpp_username` username without domain part used for authentication
|
||||
* `sendxmpp_password` password used for authentication
|
||||
|
||||
### parameter reference
|
||||
|
||||
* `recipient` jabber id of the account to receive the message
|
||||
* `jserver` jabberserver of the sending account
|
||||
* `username` username to use for authentication (_better use drone secrets_)
|
||||
* `password` password to use for authentication (_better use drone secrets_)
|
||||
|
||||
# TODO's
|
||||
|
||||
* support for self-signed certificate authorities and common ca's (_currently tls validation is disabled_)
|
||||
* support for sending messages to chat rooms instead of single users
|
||||
* customizable message template (_currently its only `repo:tag/branch:status:link`_)
|
||||
|
||||
# References
|
||||
|
||||
* [sendxmpp](http://sendxmpp.hostname.sk/) is used for sending messages
|
||||
* [shunit2](https://github.com/kward/shunit2) is used for script testing
|
||||
|
||||
Executable → Regular
+8
-8
@@ -1,18 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# set username from secret if not supplied
|
||||
[ -z "$PLUGIN_USERNAME" ] && [ -n "$SENDXMPP_USERNAME" ] && PLUGIN_USERNAME="${SENDXMPP_USERNAME}"
|
||||
[ -z "$PLUGIN_PASSWORD" ] && [ -n "$SENDXMPP_PASSWORD" ] && PLUGIN_PASSWORD="${SENDXMPP_PASSWORD}"
|
||||
[ -z $PLUGIN_USERNAME ] && [ -n $SENDXMPP_USERNAME ] && PLUGIN_USERNAME="${SENDXMPP_USERNAME}"
|
||||
[ -z $PLUGIN_PASSWORD ] && [ -n $SENDXMPP_PASSWORD ] && PLUGIN_PASSWORD="${SENDXMPP_PASSWORD}"
|
||||
|
||||
# check if all required fields are set
|
||||
[ -z "$PLUGIN_USERNAME" ] && echo "missing username or sendxmpp_username secret" && exit 123
|
||||
[ -z "$PLUGIN_PASSWORD" ] && echo "missing password or sendxmpp_password secret" && exit 123
|
||||
[ -z "$PLUGIN_JSERVER" ] && echo "missing jserver" && exit 123
|
||||
[ -z "$PLUGIN_RECIPIENT" ] && echo "missing recipient" && exit 123
|
||||
[ -z "$PLUGIN_USERNAME" ] && echo "missing username or sendxmpp_username secret" && exit 1
|
||||
[ -z "$PLUGIN_PASSWORD" ] && echo "missing password or sendxmpp_password secret" && exit 1
|
||||
[ -z "$PLUGIN_JSERVER" ] && echo "missing jserver" && exit 1
|
||||
[ -z "$PLUGIN_RECIPIENT" ] && echo "missing recipient" && exit 1
|
||||
|
||||
# create message from drone environment
|
||||
[ -n "$DRONE_TAG"] && MSG="$DRONE_REPO_NAME:$DRONE_TAG" || MSG="$DRONE_REPO_NAME:$DRONE_TAG"
|
||||
MSG="$MSG:$DRONE_BUILD_STATUS:$DRONE_BUILD_LINK"
|
||||
[ -z "$DRONE_TAG"] && MSG="$DRONE_REPO_NAME:$DRONE_TAG" || MSG="$DRONE_REPO_NAME:$DRONE_TAG"
|
||||
MSG="$MSG:$DRONE_BUILD_STATUS\n$DRONE_BUILD_LINK"
|
||||
|
||||
CMD="sendxmpp \
|
||||
-u ${PLUGIN_USERNAME} \
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
# !/bin/sh
|
||||
|
||||
setUp() {
|
||||
# if sendxmpp is present command will fail with err code 1 because of invalid domain
|
||||
# otherwise it will ultimatly fail with return code 127 aka command not found
|
||||
command -v sendxmpp > /dev/null && export EXPECTED_RETURN_CODE=1 || export EXPECTED_RETURN_CODE=127
|
||||
export PLUGIN_USERNAME="username"
|
||||
export PLUGIN_PASSWORD="password"
|
||||
export PLUGIN_JSERVER="server.invalid"
|
||||
export PLUGIN_RECIPIENT="foo@bar.invalid"
|
||||
}
|
||||
|
||||
tearDown() {
|
||||
unset PLUGIN_USERNAME
|
||||
unset PLUGIN_PASSWORD
|
||||
unset PLUGIN_JSERVER
|
||||
unset PLUGIN_RECIPIENT
|
||||
unset SENDXMPP_USERNAME
|
||||
unset SENDXMPP_PASSWORD
|
||||
}
|
||||
|
||||
testAllOk() {
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals $EXPECTED_RETURN_CODE $?
|
||||
assertTrue "[ -z "$stdout" ]"
|
||||
}
|
||||
|
||||
testMissingUsernameAndUsernameSecret() {
|
||||
unset PLUGIN_USERNAME
|
||||
unset SENDXMPP_USERNAME
|
||||
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals 123 $?
|
||||
assertEquals "missing username or sendxmpp_username secret" "$stdout"
|
||||
}
|
||||
|
||||
testUsernameSecretSet() {
|
||||
unset PLUGIN_USERNAME
|
||||
export SENDXMPP_USERNAME="secretusername"
|
||||
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals $EXPECTED_RETURN_CODE $?
|
||||
assertTrue "[ -z "$stdout" ]"
|
||||
}
|
||||
|
||||
testMissingPasswordAndPasswordSecret() {
|
||||
unset PLUGIN_PASSWORD
|
||||
unset SENDXMPP_PASSWORD
|
||||
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals 123 $?
|
||||
assertEquals "missing password or sendxmpp_password secret" "$stdout"
|
||||
}
|
||||
|
||||
testPasswordSecretSet() {
|
||||
unset PLUGIN_PASSWORD
|
||||
export SENDXMPP_PASSWORD="secretpassword"
|
||||
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals $EXPECTED_RETURN_CODE $?
|
||||
assertTrue "[ -z "$stdout" ]"
|
||||
}
|
||||
|
||||
testMissingJserver() {
|
||||
unset PLUGIN_JSERVER
|
||||
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals 123 $?
|
||||
assertEquals "missing jserver" "$stdout"
|
||||
}
|
||||
|
||||
testMissingRecipient() {
|
||||
unset PLUGIN_RECIPIENT
|
||||
|
||||
stdout=$( ../sendxmpp.sh 2> /dev/null )
|
||||
assertEquals 123 $?
|
||||
assertEquals "missing recipient" "$stdout"
|
||||
}
|
||||
|
||||
. ./shunit2
|
||||
-1137
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user