Mostrando entradas con la etiqueta github. Mostrar todas las entradas
Mostrando entradas con la etiqueta github. Mostrar todas las entradas

miércoles, octubre 10, 2012

Installing And Running Hubot, Terminator is Here


In current post we are going to see how to install hubot and make it work over XMPP protocol (using open fire server),  and how can help us during our daily work.

Hubot is a robot which belongs to your chat infrastructure as one more user, which you can talk with him. Hubot can help you automate a lot of tasks, like deploy a site, manage your Pomodoro,   or managing issue system to cite a few of them. Hubot is written in CoffeScript on Node.js, keep in mind that Hubot can be extended with CoffeScript and you can easily extend it.

This post is written using Ubuntu, so if you are using any other OS, you only have to modify the way of how components are installed.

First of all (I assume you have a JVM installed), you must install npm and node.js. For this I have used apt-get.
sudo apt-get install nodejs npm
Next step is installing Hubot dependencies by running next apt-get command.
apt-get install build-essential libssl-dev git-core redis-server libexpat1-dev
Then we need to install CoffeScript. So we can run next command:
npm install -g coffee-script
And finally we are going to install Hubot in /opt directory. Obviously could be any other one.
cd /opt
git clone git://github.com/github/hubot.git && cd hubot
npm install
Hubot is installed, to see if it works simply run from installation directory:
alex@grumpy:/opt/hubot$ ./bin/hubot
and Hubot shell will be started. This shell is really useful for testing purposes but not for production environment.
Hubot> hubot ping
Hubot> PONG
which will produce a Pong message.

Now it is time to install Openfire server so we can communicate with Hubot using XMPP protocol instead of shell. Of course you could choose any other XMPP server, but for now Openfire is used.

To install it, download it from openfire site, and extract it to /opt directory.
tar -xzvf openfire_<version>.tar.gz
mv openfire /opt
Then it is time to configure Openfire server, we are going to use embedded database but of course you can configure an external database such as MySQL or Oracle.

A web-based wizard driven setup and configuration tool is built in Openfire, so let's start Openfire server for the first time and configure typical parameters like administrator username, server name, ...
$OPENFIRE_HOME/bin/openfire start
and access to http://localhost:9090.

Then log in as admin into Openfire and create first two users, developer and hubot. So go to Users/Groups -> Create New User, and fill required information for both users.


Next step is creating a room where all users that want to interact with Hubot will join. So go to Group Chat -> Create New Room and create a new room. In our case we are going to call hubot.


and finally we must disable TLS security, there is an issue between Openfire TLS version and node.js XMPP module so if you are using Openfire, you should disable it.


Next step is checking that developer user has access to hubot chatroom and the account is correctly configured, so we can open our XMPP client (in our case Spark) but should be work with any other one and verify that we can connect.

If you are using Spark, log in with developer account and in Actions menu you will find Join Conference room option. Setthere and choose previously created room (hubot). And now you know you have configured correctly XMPP part.

And now it is time for Hubot. First of all we are going to create a bot called my-bot:
alex@grumpy:/opt/hubot$ ./bin/hubot -c ./my-bot
Then enter into my-bot directory and open package.json and add next dependencies which configure  adapter so Hubot can use XMPP protocol for communication:
"dependencies": {
    "hubot": "2.3.2",
    "hubot-scripts": ">= 2.1.0",
    "optparse": "1.0.3",
    "node-xmpp": "0.3.2",
    "hubot-xmpp": "0.1.0",
    "htmlparser": "1.7.6",
    "soupselect": "0.2.0",
    "underscore": "1.3.3",
    "underscore.string": "2.2.0rc"
  }
Then before starting Hubot, you must install XMPP adapter. Run from hubot directory npm install, and XMPP extension will be installed into hubot.
alex@grumpy:/opt/hubot/my-bot$ npm install
And now we are ready to start using Hubot and Openfire.

We are going to start by adding environment variables to configure XMPP adapter.
export HUBOT_XMPP_USERNAME=hubot@grumpy
export HUBOT_XMPP_PASSWORD=<password>
export HUBOT_XMPP_ROOMS=hubot
Note that username should be accompanied for server name which in my case is grumpy. And finally it is time to start Hubot.
alex@grumpy:/opt/hubot/my-bot$ ./bin/hubot --adapter xmpp
And you will see at Spark your new friend (if you have already add hubot as a friend).


And after you check that we can go to hubot-scripts and download and install the useful ones depending on our environment.

In next video you could see a screencast of Hubot In Action with some scripts that I use.



I wish you have liked Hubot,

We keep learning,
Alex.


A Time For Us, At Last To See, A Life Worthwhile, For You And Me (A Time For Us - Andy Williams)
Music: http://www.youtube.com/watch?v=sRnx-s1TQbU

lunes, septiembre 12, 2011

Questa di Marinella è la storia vera Che scivolò nel fiume a Primavera Ma il vento che la vide così bella Dal fiume la portò sopra una stella (Canzone Di Marinella - Mina)




Most of us use Maven as a build automation tool. One of most important section are those related to dependencies. Typically projects have dependencies to external libraries like Spring, Hibernate, Slf4j, ... which are downloaded from External Maven Repository Servers like mvnrepository, ibiblio or from own Internal Maven Repository Server using JFrog or Nexus. This scenario but does not cover all possible cases.

It is uncommon that your project requires an external library that is not present in any repository, but can occurs, and in these cases are where you use company Internal Maven Repository to upload these artifacts. But this is not always possible, and typical example is when you are writing in a blog about a beta library and it is not present in any repository, and you want to add this library to pom file. Would be perfect if Maven could resolve these dependencies too without packaging them into project. So what can we do?

There are some alternatives:

- packaging .class files of external library into your project, so they are packaged as project files.
- asking library creators to upload Milestones to public repositories.
- create your own public Maven Repository.
- using GitHub?

Using GitHub, YES!!. You can configure your GitHub account as Maven Repository. In my case I always upload sample code to GitHub. Why not creating a GitHub project that acts as a Maven Repository and poms referencing to this repository?

Now I will summarize steps that shall be followed: (assuming that you have already created a project).
  1. Create a GitHub repository.
  2. Initialize local directory as Git repo.
  3. Modify project pom so distribution management tag points to local repository.
  4. Perform deploy goal so artifact is deployed to local repository.
  5. Push changes to GitHub.
  6. Nothing more. Now other project poms can use your repository.

Let's get down to work:

The first thing you should know is that the project I want to upload to Maven Repository is located at /media/share/workspace/github-test and project that will have a dependency will be located at /media/share/workspace/bar.

First step is creating a new GitHub repository. So login to your GitHub account and create a new repository. In my case I have named maven-repository.


Second step is initialize local directory as Git repository.

Third step is adding distributionManagement tag pointing to repository so when project is deployed, artifact is created to Git directory.

See that url tag is pointing to previously created Git directory (local disk).

Fourth Step is running mvn -DperformRelease=true clean deploy. Project is compiled, tested, and packaged. Now go to local repository and see what has appeared.

Fifth Step implies two operations, committing changes and pushing them to GitHub.

See that first command is adding root directory. Then all files are committed to local repository and pushed to GitHub repository.


Sixth Step if you want to call it step, is adding repository tag to project that requires published component. In our case bar project requires it.

This pom represents a project that wants to use github-test module. It is important to note that repository url is special (not showed when you explore GitHub projects with navigator), and is https://github.com/maggandalf/maven-repository/raw/master. After repository name (in this case maven-repository) you should concatenate /raw/master. raw because you want to access to files without any decoration (no HTML), and master because it is the branch name.

When bar project is being compiled, github-test artifact is downloaded.


I think it is a good approach when you need to upload a Maven artifact temporally, or simply because your project requires a milestone version of artifact that is not uploaded into any repository.

I hope you like this post, and ... MOVE TO GIT.

Music: http://www.youtube.com/watch?v=TL69oTe6HHY