Jenkins is one of the best open-source Continuous Integration server available. It helps in automating the builds and sharing of the application with minimal or no user interaction. In this post we are going to set up continuous integration server Jenkins for Android projects. Later this post will be extended for flavor specific build creation and sharing.
- Ubuntu 16.04 server with root access
In this article following two topics will be covered:
- Installation of Jenkins on Ubuntu 16.04
- Configure Jenkins access
- Configure for Android Projects
1. Installation of Jenkins on Ubuntu 16.04:
In order to do this, login to the server with root access (in other words, access to terminal with #). Run following command to add the key of Jenkins to the machine.
root@pcsalt:~# wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add - OK
Here “OK” is output for successfully adding the key. If you are not logged in as root user, then you might receive following message.
ERROR: This command can only be used by root.
Now, create a source list for Jenkins
root@pcsalt:~# echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
Running this command will not generate any output. You can verify the success by running the following command. It will return the content of the list file we just created. If not, then make sure you are using it as root user.
root@pcsalt:~# cat /etc/apt/sources.list.d/jenkins.list deb http://pkg.jenkins-ci.org/debian binary/
After this step, we have to refresh the apt’s cache. After this we can install Jenkins.
root@pcsalt:~# apt update
As soon as the refresh process is done, you might receive list and count of upgradable packages (which you can ignore for now). Since, the list has been updated with Jenkins list, we can now install it by running following command.
root@pcsalt:~# apt install jenkins
For me, it is downloading 72.9 MB of data (it may vary over time). Give it some time, then you will be done with the installation of Jenkins on the server.
2. Configure Jenkins access:
After installation is completed, use the browser to navigate to the newly installed Jenkins server. URL for it will be <server-ip-or-domain-name>:8080. Since, we are using local Ubuntu server, for us the access URL will be:
As mentioned on the page, copy and paste the text from /var/lib/jenkins/secrets/initialAdminPassword. User following command to get the content of the mentioned file.
root@pcsalt:~# cat /var/lib/jenkins/secrets/initialAdminPassword 5262ad961537445989b08efd13ebe359
Copy the text from YOUR terminal to the Jenkins initial page. Click “Continue” to proceed. It will open a page and will prompt which type of customization you want, we selected Select plugins to install option.
In next screen, it will ask for plugin selection, if you are not sure then leave the options as it is.
As you are done with the selection, click on the “Next” button to begin the installation of the plugins.
After the plugin installation is completed, Jenkins will ask to create a user or skip the process to continue as administrator.
If you skip the user creation process, then you have to use following credential for login:
Username: admin Password: <content-of-/var/lib/jenkins/secrets/initialAdminPassword>
Whichever option you choose, you will reach following screen after login.
3. Configure for Android Projects:
On Jenkins dashboard either click “New Item” or since, there are no project therefore, click “create new jobs”. Now, in the new job page provide the name of the job “demo-project” and select “Freestyle Project”. Then click “OK” button.
A new job by the name demo-project will be created and Jenkins will redirect to the configuration screen of the job. For demo purpose I am using a public project, so that, I do not have to use any other configuration.
After making following changes to the job click on Save button.
*General **Project name: demo-project *Source Code Management **Git ***Repositories ****Repository URL: https://github.com/krrishnaaaa/guideline-view-demo.git *Build **Use Gradle Wrapper ***Make gradlew executable : enable ***Tasks: clean assemble *Post-build Actions **Files to archive: *.apk