sábado, 9 de junio de 2012

Cloudbees PaaS

Six months ago, I was looking for subversion server. I could have used Google code, but I had a problem with that, it is a public repository. So, I found Cloudbees.

Cloudbees is a PaaS. What's Paas? Nowadays, we should know about Platform as a Service. But, it doesn't matter if you don't know it. We are for help us. Briefly, PaaS is a environment on cloud based on products from the providers. In this case, Cloudbees was built using Sonar, Jenkins, Subversion, Git, MySQL, Tomcat.

What can I find on Cloudbees? You can find several products such as I have mentioned before, besides JFrog, SendGrid, AppDynamics, New Relic, Mongo HQ.

I think that we can try it for demos and small project, maybe at university. Sometimes we need to application server, and using Cloudbees we can have source control management, database, application server, maven repository.

We have to consider that Cloudbees provide a limit space, if you want more space you have to buy.
Cloudbees, is a good service. And I hope you can use it.

Development Environment

In this blog, I going to talk about some tools. Maybe, you has heard about those.

Source Control Management (SCM)
At the moment, we are several people that works with Subversion or Git, both useful but perhaps one more popular than other.
Using whatever, we can share our code with all the team, and we can work together. Also, is not necessary send files by email, because SCM is charge off the keep the last code, and if we make a mistake in the last code we can see all the historical code.

Mercurial and CVS are also SCM.
If we going to start with collaborative project and share our code, we can use Google Code or Github. I think that, both are goods products.

Is a java tool. If we use maven we can manage our project's life cycle. we can use some commands for compile the code, create the artifact (jar, ear, war), run our test, upload the artifact to repository.

Some commands:

Besides, maven allow us run embedded server such as tomcat, jetty.
Using maven, we can forget about search jars and their dependencies. Maven download the jar that we want to use and their dependencies too. That's awesome.

Currently, we are working with maven projects. But, if we are big group and we are working in the same project. We can use Nexus Repository.
Using that, we are allowed to create local repository for our projects and upload our artifacts (jar, ear, war). We can also create proxies repositories, i.e. for our project we need to use jboss libraries, but in the Central Repository we can't find this jar. We can add another repository, in this case: https://repository.jboss.org/nexus/content/repositories/releases/

Here, others repositories:

Tool charge of keep measure about projects. Identify duplicate code, measure your code, measure complexity cyclomatic, identify bad practices and recommend how to solve. The last depend on the rule configured.

In the following URL http://nemo.sonarsource.org/ , you can see several open source projects.

Hudson or Jenkins
Is the most popular Continuous Integration (CI) server. Here, we can works with all tools that we have mentioned in this blog. We can download the maven project from the SCM and this will charge of looking for dependencies on Nexus Repository and update the last measures on Sonar server.

We can automate several functions. CI server use jobs, could have one job for deploy on production environment, other for update measure on Sonar, the last maybe analyze our code each 1 hour.

We can have this tools in our environment, but you shouldn't forget that we need practices and polices, in order to have a good control over the team and the projects.

Code Coverage with Sonar and Maven

Code coverage is a measure. This measure indicate us about the code that has been tested.
Having 100% to code coverage, we can avoid risk while we change the code.
What I need to analyze? When I refer to analyze, I want to say that you need to do unit test and test all the scenarios that exist. While you have high code coverage that's mean that you have more scenarios covered.
Nowadays, we can use Sonar Analyzer Tool, it is a free tool.
If you want to analyze your code and you use maven for your java projects. You only need to add this dependency:

Finally, at root path you can use shell command.

Gist by Github

I was looking for styles in order to put good style at my code in my blog.
First, I tried with SyntaxHighlighter, it was useful in that moment but I needed to modify blog's source code. Fortunately, I found Gist.
Here, some example. I hope it will be useful.

Note: You can use Gist using your GitHub account. But, if you haven't it, don't worry you can use it too.