Skip to content

Commit

Permalink
Merge pull request #4 from xebialabs-community/TeamInboxTask
Browse files Browse the repository at this point in the history
Team inbox task
  • Loading branch information
jdewinne authored Nov 30, 2017
2 parents c589e7d + ec93b71 commit 46920a2
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 9 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Preface #
# Preface

This document describes the functionality provided by the XL Release Flowdock plugin.

Expand All @@ -22,24 +22,29 @@ See the [XL Release Documentation](https://docs.xebialabs.com/xl-release/) for b



# Overview #
## Overview

The XL Release Flowdock plugin is a XL Release plugin that adds capability for sending message to a Flowdock inbox.

# Requirements #
## Requirements

* **Requirements**
* **XL Release** 6.0.x+

# Installation #
## Installation

Place the plugin JAR file into your `SERVER_HOME/plugins` directory.

# Usage #
## Usage

### Event based notifications

1. Go to `Settings - Shared configuration - Flowdock: Configuration`
2. Add a new configuration
3. Provide Title (Can be anything), API url (eg: https://api.flowdock.com), Flow token (See your Flow configuration in Flowdock) and enable or disable the Flowdock configuration.
![Flowdock configuration](images/Flowdock_configuration.png?raw=true "Flowdock configuration")
4. Each time XL Release stores something into the Activity logs, this will also be send to Flowdock.

### Tasks

+ SendTeamInboxMessage: Allows to send a specific message to a TeamInbox.
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "com.github.hierynomus.license" version "0.14.0"
id "com.xebialabs.xl.docker" version "1.1.0"
id 'nebula.release' version '6.0.0'
id "com.github.hierynomus.jython" version "0.8.0"
}

apply plugin: 'java'
Expand Down Expand Up @@ -42,12 +43,19 @@ dependencies {
compile "com.xebialabs.deployit:engine-api:$apiVersion"
compile group: "com.xebialabs.xl-platform", name: "xl-repository-api", version: "$apiVersion", transitive: false
compile "nl.javadude.t2bus:t2-bus:1.2.1"
jython ":requests:2.11.1"
jython(":python-flowdock:0.1") {
artifact {
name = "flowdock"
extension = "py"
}
}
}


license {
header rootProject.file('License.md')
strictCheck false
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'XEBIALABS'
excludes(["**/requests/**/*.py", "**/flowdock.py"])
}
18 changes: 18 additions & 0 deletions src/main/resources/caflowdock/FlowdockHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2017 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

class FlowdockHelper(object):

def __init__(self):
return

@staticmethod
def get_token(variables):
return variables['flowToken'] if variables['flowToken'] else variables['flowdockServer']["flowToken"]
18 changes: 18 additions & 0 deletions src/main/resources/caflowdock/SendTeamInboxMessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2017 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

import flowdock

from caflowdock.FlowdockHelper import FlowdockHelper

api_key = FlowdockHelper.get_token(locals())
fdclient = flowdock.FlowDock(api_key=api_key, app_name=appName, project=project)

fdclient.post(fromAddress, subject, content, from_name = fromName, tags=tags, link=link)
32 changes: 32 additions & 0 deletions src/main/resources/caflowdock/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright 2017 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

import os
import tempfile
from com.xebialabs.xlr.ssl import LoaderUtil
from java.nio.file import Files, Paths, StandardCopyOption

def set_ca_bundle_path():
ca_bundle_path = extract_file_from_jar("requests/cacert.pem")
os.environ['REQUESTS_CA_BUNDLE'] = ca_bundle_path


def extract_file_from_jar(config_file):
file_url = LoaderUtil.getResourceBySelfClassLoader(config_file)
if file_url:
tmp_file, tmp_abs_path = tempfile.mkstemp()
tmp_file.close()
Files.copy(file_url.openStream(), Paths.get(tmp_abs_path), StandardCopyOption.REPLACE_EXISTING)
return tmp_abs_path
else:
return None

if 'REQUESTS_CA_BUNDLE' not in os.environ:
set_ca_bundle_path()
Binary file added src/main/resources/caflowdock/flowdock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 22 additions & 3 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,30 @@
-->
<synthetic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.xebialabs.com/deployit/synthetic" xsi:schemaLocation="http://www.xebialabs.com/deployit/synthetic synthetic.xsd">
xmlns="http://www.xebialabs.com/deployit/synthetic"
xsi:schemaLocation="http://www.xebialabs.com/deployit/synthetic synthetic.xsd">

<type type="flowdock.configuration" extends="xlrelease.Configuration">
<property name="apiUrl" category="input" label="API url" required="true" default="https://api.flowdock.com"/>
<property name="flowToken" category="input" label="Flow Token" required="true" />
<property name="enabled" category="input" label="Enabled" kind="boolean" />
<property name="flowToken" category="input" label="Flow Token" required="true"/>
<property name="enabled" category="input" label="Enabled" kind="boolean"/>
</type>

<type type="flowdock.SendTeamInboxMessage" extends="xlrelease.PythonScript">
<property name="scriptLocation" default="caflowdock/SendTeamInboxMessage.py" hidden="true"/>
<property name="iconLocation" default="caflowdock/flowdock.png" hidden="true"/>
<property name="flowdockServer" category="input" label="Server" referenced-type="flowdock.configuration"
kind="ci"/>

<property name="flowToken" category="input" label="Flow Token" required="false" description="If not configured, the configuration token will be used."/>
<property name="appName" category="input" label="Application Name" required="true" default="Python FlowDock" description="Your app name (defaults to 'Python FlowDock')"/>
<property name="project" category="input" label="Project" required="false" description="Defaults to nothing" />
<property name="fromAddress" category="input" label="From Address" required="true" description="[email protected]"/>
<property name="subject" category="input" label="Subject" required="true" description="Subject of your post" />
<property name="content" category="input" label="Content" required="true" description="HTML body for your post" size="large"/>
<property name="fromName" category="input" label="From Name" required="false" description="a human-readable name to go along with the from_address" />
<property name="tags" category="input" label="Tags" required="false" kind="list_of_string" description="a list of strings to tag this post with" />
<property name="link" category="input" label="Link" required="false" description="a URL to associate with this post" />

</type>
</synthetic>

0 comments on commit 46920a2

Please sign in to comment.