<commit_before>---
title: Continuous Integration
layout: tutorial
lprev: 700-deploy.html
lnext: /book/220-tutorial-base.html#End
summary: How to setup a Git project and run a Continuous Integration server
---

## What You Will Learn in This Section

In this section we will first see how our current bnd workspace has built in build support through Gradle. Though this can be useful for some local work, the primary purpose is to do continuous integration. So we push the project to Github and set up a Travis Continuous Integration server.

## Building Outside the IDE

If you can't automatically build your product then you're not a software engineer! One of the giant steps of software engineering was when we came from the cave
of releasing code from our personal machines and moved into the world of continuous integration. It is amazing how many unwanted dependencies creep up when you
build on a personal system. Automating repeated processes is at the heart of building software. This is why OSGi enRoute (well, bnd) includes a full gradle build that does not require any extra work, you're basically already setup. The _raison d'être_ of bnd is that it runs inside an IDE like Eclipse but can also run from a shell. Great care has been taken to ensure that bnd builds virtual identical artifacts inside the IDE and from the command line. 

So we only have to fire up a shell and run the build!

You do not even need to have gradle installed. There is a script included, `gradlew`, that will download the correct gradle version. You can also install gradle (>= 1.12) and use it. It should go without saying, but you should also have java 8 installed on the command line.

	$ cd /Users/aqute/git/com.acme.prime
	$ java -version
	java version "1.8.0"
	Java(TM) SE Runtime Environment ...
	$ ./gradlew
	Downloading https://b../biz.aQute.bnd-latest.jar to 
	    /Users/aqute/git/com.acme.prime/cnf/cache/biz.aQute.bnd-latest.jar ...
	:help
	
	Welcome to Gradle 1.12.
	To run a build, run gradlew <task> ...
	To see a list of available tasks, run gradlew tasks
	To see a list of command-line options, run gradlew --help
	BUILD SUCCESSFUL
{: .shell }

For almost all features of bndtools there is a corresponding gradle task you can execute. You can see all the possible tasks with `./gradlew tasks`. For example, you automatically get a task to build your `com.acme.prime.eval` application:

	$ ./gradlew export.com.acme.prime.eval
	:com.acme.prime.eval.api:compileJava
	:com.acme.prime.eval.api:processResources UP-TO-DATE
	:com.acme.prime.eval.api:classes
	:com.acme.prime.eval.api:jar
	Warning: Please update this Bundle-Description in com.acme.prime.eval.api/bnd.bnd
	:com.acme.prime.eval.api:assemble
	:com.acme.prime.eval.api:export.hello
	Plugin found aQute.launcher.plugin.ProjectLauncherImpl 1.4.0.201406101507

	BUILD SUCCESSFUL
{: .shell }

This task will store the output in `com.acme.prime.eval.api/generated/distributions/executable/com.acme.prime.eval.jar`.

## Putting it on Github

We should now create a repository on Github, for which you will need an account. There is a nice tutorial about [setting up new repositories on Github][1] but we take it here one by one.

Lets call this new repository the same as the workspace `com.acme.prime`. So go to your home page and click on te `+` on the top and select `New Repository`.

![Create new repo](/img/tutorial_base/ci-github-0.png)

This will open the window where we can define our repository information. Be nice, also add a description ...

![Create new repo](/img/tutorial_base/ci-github-1.png)

We then click on `Create Repository` which brings us on a page that explains how to connect our local repository in `~/git/com.acme.prime.eval` to this repository on Github. In our case, we want to connect a brand new repository, even though our current Git workspace is still connected to the OSGi `workspace` repository, and it is highly unlikely you can write that repository.

![Create new repo](/img/tutorial_base/ci-github-2.png)

We will follow the first scenario but we want to use the SSH URI, so click on the `SSH` button and copy the URI in the adjoining text box to the clipboard. It should be something like:<commit_msg>Minor text correction in base tutorial Signed-off-by: <NAME> <<EMAIL>><commit_after>---
title: Continuous Integration
layout: tutorial
lprev: 700-deploy.html
lnext: /book/220-tutorial-base.html#End
summary: How to setup a Git project and run a Continuous Integration server
---

## What You Will Learn in This Section

In this section we will first see how our current bnd workspace has built in build support through Gradle. Though this can be useful for some local work, the primary purpose is to do continuous integration. So we push the project to Github and set up a Travis Continuous Integration server.

## Building Outside the IDE

If you can't automatically build your product then you're not a software engineer! One of the giant steps of software engineering was when we came from the cave
of releasing code from our personal machines and moved into the world of continuous integration. It is amazing how many unwanted dependencies creep up when you
build on a personal system. Automating repeated processes is at the heart of building software. This is why OSGi enRoute (well, bnd) includes a full gradle build that does not require any extra work, you're basically already setup. The _raison d'être_ of bnd is that it runs inside an IDE like Eclipse but can also run from a shell. Great care has been taken to ensure that bnd builds virtual identical artifacts inside the IDE and from the command line. 

So we only have to fire up a shell and run the build!

You do not even need to have gradle installed. There is a script included, `gradlew`, that will download the correct gradle version. You can also install gradle (>= 1.12) and use it. It should go without saying, but you should also have java 8 installed on the command line.

	$ cd /Users/aqute/git/com.acme.prime
	$ java -version
	java version "1.8.0"
	Java(TM) SE Runtime Environment ...
	$ ./gradlew
	Downloading https://b../biz.aQute.bnd-latest.jar to 
	    /Users/aqute/git/com.acme.prime/cnf/cache/biz.aQute.bnd-latest.jar ...
	:help
	
	Welcome to Gradle 1.12.
	To run a build, run gradlew <task> ...
	To see a list of available tasks, run gradlew tasks
	To see a list of command-line options, run gradlew --help
	BUILD SUCCESSFUL
{: .shell }

For almost all features of bndtools there is a corresponding gradle task you can execute. You can see all the possible tasks with `./gradlew tasks`. For example, you automatically get a task to build your `com.acme.prime.eval` application:

	$ ./gradlew export.com.acme.prime.eval
	:com.acme.prime.eval.api:compileJava
	:com.acme.prime.eval.api:processResources UP-TO-DATE
	:com.acme.prime.eval.api:classes
	:com.acme.prime.eval.api:jar
	Warning: Please update this Bundle-Description in com.acme.prime.eval.api/bnd.bnd
	:com.acme.prime.eval.api:assemble
	:com.acme.prime.eval.api:export.hello
	Plugin found aQute.launcher.plugin.ProjectLauncherImpl 1.4.0.201406101507

	BUILD SUCCESSFUL
{: .shell }

This task will store the output in `com.acme.prime.eval.appplication/generated/distributions/executable/com.acme.prime.eval.jar`.

## Putting it on Github

We should now create a repository on Github, for which you will need an account. There is a nice tutorial about [setting up new repositories on Github][1] but we take it here one by one.

Lets call this new repository the same as the workspace `com.acme.prime`. So go to your home page and click on te `+` on the top and select `New Repository`.

![Create new repo](/img/tutorial_base/ci-github-0.png)

This will open the window where we can define our repository information. Be nice, also add a description ...

![Create new repo](/img/tutorial_base/ci-github-1.png)

We then click on `Create Repository` which brings us on a page that explains how to connect our local repository in `~/git/com.acme.prime.eval` to this repository on Github. In our case, we want to connect a brand new repository, even though our current Git workspace is still connected to the OSGi `workspace` repository, and it is highly unlikely you can write that repository.

![Create new repo](/img/tutorial_base/ci-github-2.png)

We will follow the first scenario but we want to use the SSH URI, so click on the `SSH` button and copy the URI in the adjoining text box to the clipboard. It should be something like:
{'fraction_non_alphanumeric': 0.07114204813591317, 'fraction_numerical': 0.00825861255309108, 'mean_word_length': 4.024896265560166, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7285563', 'n_tokens_mistral': 2504, 'n_tokens_neox': 2365, 'n_words': 1191}