Monday, 16 June 2014

Jekins and Android - Dependencies between jobs

If several code of the same project are stored in different repositories, such as the case of libraries, several jobs must be created since each job can only retrieve the code from on repository. In this case, there is a special way to execute the jobs related.

I am going to use an example to show this. Let's say we have a project called Main in the repository 1. This project depends on a library called library1 stored in the repository 2.

1. Configure the project.
In the project.profile of the project Main, it must have a relative path to the library1 directory IN JENKINS, not in the local computer. This could be the content:

android.library.reference.1=../../Library1/workspace

where "Library1" is the name of the job which is related with library1 configured in Jenkins.

Note that there are two levels "up"s. The first one is because the actual directory is in the folder workspace inside of the actual job, the second one is used to go back to the job level, where all the jobs have their own folder.

Once there, it goes to the job "Library1" and inside that folder, the folder workspace, where the data of the last stable compilations goes.

Now commit (and push) the changes to the repository.

2. Download this plugin for Jenkins, which is used to execute one project after another:
https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin

3. Creates a new project of build flow
3.1 On the home screen of Jenkins, click on new job
3.2 Enter the name of the job. Select the type of job as "Build Flow"
3.3 In the config of the project, under "Execution trigger", there will be a special windows called "Define build flow using flow DSL". Enter the follow lines

build("Main")
build("Library1")

Where Main is the name of the job in Jenkins which is related with the project Main.

Source:
StackOverFlow - Ant Build Android Project with Dependencies

No comments:

Post a Comment