Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwille committed Aug 31, 2010
1 parent 6944abe commit 754ffc6
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ccnet.TwitterPublisher.plugin", "ccnet.TwitterPublisher.plugin\ccnet.TwitterPublisher.plugin.csproj", "{50E91E10-B75A-4379-AC37-DECC8927EAD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{50E91E10-B75A-4379-AC37-DECC8927EAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50E91E10-B75A-4379-AC37-DECC8927EAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50E91E10-B75A-4379-AC37-DECC8927EAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50E91E10-B75A-4379-AC37-DECC8927EAD4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
@@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ccnet.TwitterPublisher.plugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ccnet.TwitterPublisher.plugin")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,156 @@
using System;
using System.Net;
using System.Web;

using Exortech.NetReflector;

using ThoughtWorks.CruiseControl.Core;
using ThoughtWorks.CruiseControl.Core.Util;
using ThoughtWorks.CruiseControl.Remote;

namespace ccnet.TwitterPublisher.plugin
{
[ReflectorType("twitter")]
public class TwitterPublisher : ITask
{
private const string UPDATE_STATUS_URL = "http://twitter.com/statuses/update.xml?status={0}";

private string _user;
private string _password;
private string _proxyHost;
private int _proxyPort = -1;
private string _proxyBypassList;
private bool _proxyBypassOnLocal;
private string _proxyUsername;
private string _proxyPassword;

#region Public properties

[ReflectorProperty("user", Required = true)]
public string User
{
get { return _user; }
set { _user = value; }
}

[ReflectorProperty("password", Required = true)]
public string Password
{
get { return _password; }
set { _password = value; }
}

[ReflectorProperty("proxyHost", Required = false)]
public string ProxyHost
{
get { return _proxyHost; }
set { _proxyHost = value; }
}

[ReflectorProperty("proxyPort", Required = false)]
public int ProxyPort
{
get { return _proxyPort; }
set { _proxyPort = value; }
}

[ReflectorProperty("proxyBypassList", Required = false)]
public string ProxyBypassList
{
get { return _proxyBypassList; }
set { _proxyBypassList = value; }
}

[ReflectorProperty("proxyBypassOnLocal", Required = false)]
public bool ProxyBypassOnLocal
{
get { return _proxyBypassOnLocal; }
set { _proxyBypassOnLocal = value; }
}

[ReflectorProperty("proxyUsername", Required = false)]
public string ProxyUsername
{
get { return _proxyUsername; }
set { _proxyUsername = value; }
}

[ReflectorProperty("proxyPassword", Required = false)]
public string ProxyPassword
{
get { return _proxyPassword; }
set { _proxyPassword = value; }
}

#endregion

public void Run(IIntegrationResult result)
{
if (result.Status == IntegrationStatus.Unknown)
return;

string status = CreateStatus(result);
try
{
string url = String.Format(UPDATE_STATUS_URL, HttpUtility.UrlEncode(status));

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
IWebProxy proxy = GetWebProxy();
if (proxy != null)
webRequest.Proxy = proxy;
webRequest.Method = "POST";
webRequest.ServicePoint.Expect100Continue = false;
webRequest.KeepAlive = false;
webRequest.ContentType = "application/xml";
webRequest.Accept = "application/xml";
webRequest.Credentials = new NetworkCredential(_user, _password);

webRequest.GetResponse();

Log.Info("Integration results published on twitter");
}
catch (Exception e)
{
Log.Error(e);
}
}

private IWebProxy GetWebProxy()
{
if (!String.IsNullOrEmpty(_proxyHost) && _proxyPort > 0)
{
WebProxy proxy = new WebProxy(_proxyHost, _proxyPort);

if (!String.IsNullOrEmpty(_proxyBypassList))
proxy.BypassList = _proxyBypassList.Split(',');
proxy.BypassProxyOnLocal = _proxyBypassOnLocal;

if (!String.IsNullOrEmpty(_proxyUsername) && !String.IsNullOrEmpty(_proxyPassword))
proxy.Credentials = new NetworkCredential(_proxyUsername, _proxyPassword);

return proxy;
}

return null;
}

private static string CreateStatus(IIntegrationResult result)
{
if (result.Status == IntegrationStatus.Success)
{
if (result.LastIntegrationStatus != result.Status)
{
return String.Format("{0} Build Fixed: Build {1}. See {2}", result.ProjectName, result.Label, result.ProjectUrl);
}
else
{
return String.Format("{0} Build Successful: Build {1}. See {2}", result.ProjectName, result.Label, result.ProjectUrl);
}
}
else
{
return String.Format("{0} Build Failed. See {1}", result.ProjectName, result.ProjectUrl);
}
}
}
}
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{50E91E10-B75A-4379-AC37-DECC8927EAD4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ccnet.TwitterPublisher.plugin</RootNamespace>
<AssemblyName>ccnet.TwitterPublisher.plugin</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="NetReflector, Version=1.0.0.120, Culture=neutral, PublicKeyToken=2f4dd8b32acbcd8e">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\NetReflector.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml" />
<Reference Include="ThoughtWorks.CruiseControl.Core, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\ThoughtWorks.CruiseControl.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ThoughtWorks.CruiseControl.Remote, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\ThoughtWorks.CruiseControl.Remote.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="TwitterPublisher.cs">
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions BuildServer/ccnet.TwitterPublisher.plugin/readme.txt
@@ -0,0 +1,4 @@
From:

http://thomasfreudenberg.com/blog/archive/2007/06/17/twitter-publisher-for-cruisecontrol-net.aspx

0 comments on commit 754ffc6

Please sign in to comment.