The Twitter activity can be used to send a tweet from within a build workflow. In this example we aim to show the the basic steps that are required to get the activity integrated into a build.
Before you can make use of any of the
TFS community build activities you have to make sure they are available for the build system and on your development PC. Instructions for this process can be found in the
ALM Rangers build guide or in the
StyleCop page of this wiki. This page assumes the Twitter activity is available in the developers build process workflow toolbox.
Configuration of Twitter
To allow TFS build to be able to send a Tweet you need to register an application on your Twitter account.
- Go to http://dev.twitter.com and login with the Twitter account details you wish to be able to send Tweets from
- Select the My Application from drop down on the top right
- Press the Create new application button
- On the resultant form enter the following information and press the create button
- Name – the name of your application e.g. TFSBuild
- Description – which has to be 10 characters or more
- Website – this is the URL that will shows as link in a Twitter client as the sending application. If clicked the URL will be opened, this could be used as a link back to your build status reports. You have to enter a URL so if you are not
going to use it, either enter a fake URL or just your default company site
- CallBack URL – not needed for the this activity
- IMPORTANT before you generate the tokens you need, you must set the access level for your new application. If you generate the tokens before making this change you will not be able to send Tweets.
- On the new applications select the settings tab and select the Read, Write and Access direct messages
access level and save the changes
- On the Details tab press the Create Access Keys, you should now have the four tokens you needs
Configuring the activity
Using the Twitter activity is very straight forward, once it is dropped onto the build process design surface only the message and token properties have to be set to send a Tweet.
The activity can be used at any point in the build process you wish to Tweet.
- AccessToken – from your application on the Twitter
- AccessTokenSecret – from your application on the Twitter
- ConsumerKey – from your application on the Twitter
- ConsumerSecret – from your application on the Twitter
- Message – The message you wish to Tweet, this will usually be a built depending the success or failure of the build
Running the activity
When you run the build you should see the Tweet sent.
If you have the tokens wrong, or did not set the access level you will see a ‘System.Net.WebException: The remote server returned an error: (401) Unauthorized.’ error.