ECT

Etoile Cercle Triangle - Star Circle Triangle

Octopress continous integration

| Comments

Update 2012-11-30: update script to adapt to last Cloudbees changes.

Octopress is great for blogging:

This blog is powered by Octopress.

But Octopress relies on Ruby rake to generate and deploy your blog posts, so you need to install them on each computer from where you want to deploy your blog. And installing theses tools are generally a pain: ruby/rvm, rake, bundler, encoding issues between platforms, …

So the perfect “blog post flow” would be:

  1. write blog post everywhere: laptop, personnal/professional computer, …
  2. generate and deploy from only one place

I found a centralized place to generate and deploy this blog: a Cloudbees Jenkins instance! Jenkins is a continuous integration server, which allows you to build and deploy Java, Ruby, … applications.

What about a ruby/rake/bundler build ?

Configure a new free-style projet, with the following shell job:

1
2
3
4
5
6
7
8
9
10
11
#export LC_ALL=fr_FR.UTF-8 # uncomment this if you need to force locale
#export LANG=fr_FR.UTF-8  # uncomment this if you need to force locale
curl -s -o use-ruby https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/ruby/use-ruby
RUBY_VERSION=1.9.3-p327 \
source ./use-ruby
ln -fs /scratch/jenkins/ruby /scratch/jenkins/rubies
gem install --conservative bundler
bundle install
rake setup_github_pages[git@github.com:dlecan/dlecan.github.com.git]
rake generate
rake deploy

That’s it! Just replace git@github.com:dlecan/dlecan.github.com.git by your Git repository and let Jenkins do the job for you!

This blog is also built thanks to Cloudbees :)

See it in action on this Cloudbees Jenkins instance.

How to publish Play2 ‘dist’ package ?

| Comments

In an enterprise context, it is often necessary to deploy (maven) or publish (Ivy/SBT) artifacts in a central repository.

Here is a sample Play2 project configured to publish artifact in a local folder (~/.ivy2/publish), but you can easily adapt it to publish to your central repository (Nexus, Artifactory, …)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

  val appName = "sample"
  val appVersion = "1.0-SNAPSHOT"

  // Properties to add configure the new Artifact
  lazy val distSettings = Seq[Setting[_]] (

    // Type of the Artifact : zip
    // Extension of the Artifact : zip
    artifact in dist <<= moduleName(n => Artifact(n, "zip", "zip"))
  ) ++ Seq(addArtifact(artifact in (Compile, dist), dist).settings: _*)

  val appDependencies = Seq(
    // Add your project dependencies here,
  )

  val main = PlayProject(appName, appVersion, appDependencies,
                         mainLang = SCALA,
                         // Don't forget to add defaultSettings !
                         settings = Defaults.defaultSettings ++ distSettings
             ).settings(

    // Optional
    // Disable jar for this project (useless)
    publishArtifact in (Compile, packageBin) := false,

    // Disable scaladoc generation for this project (useless)
    publishArtifact in (Compile, packageDoc) := false,

    // Disable source jar for this project (useless)
    publishArtifact in (Compile, packageSrc) := false,

    // Where to 'publish'
    publishTo := Some(Resolver.file("file", file(Path.userHome.absolutePath + "/.ivy2/publish"))),

    // Use Maven pattern to publish
    publishMavenStyle := true)
}

Next step: to be able to “release” a Play2 project with SBT (update version in project, tag, build and publish artifacts).