This Docker Project uses nginx and jenkins docker official images. You will be able to use nginx as a reverse proxy server to access jenkins automation server.
Note: All server configurations in nginx are made to work on a local environment.
If you want to implement the complete Continuous Integration Flow for your development process, so take a look at our Medium Post.
- Install
Docker
andDocker Compose
. - At top level project run
docker-compose up
command from terminal. - Go to terminal and run:
docker ps
You will see two running containers as follows:
CONTAINER ID IMAGE ... PORTS NAMES
621282adb463 jenkinsandroid_nginxservice ... 0.0.0.0:80->80/tcp ...jenkinsandroid_nginxservice_1
4dd4d4c68b65 jenkinsandroid_jenkinsservice ... 8080/tcp, 50000/tcp ..jenkinsandroid_jenkinsservice_1
- Access to the running nginx container:
docker exec -i -t dockernginxjenkinsandroid_nginxservice_1 sh
- Inside the nginx docker container, we must create your own user basic auth
htpasswd -b -C 5 /etc/apache2/.htpasswd YOUR_USER_NAME YOUR_PASSWORD
- You will be prompted to write a password.
- That's all, you have a nginx basic auth now.
Go to http://localhost/jenkins and you will be prompted to write you user authentication, write your YOUR_USER_NAME and YOUR_PASSWORD as we explain above and could access to the jenkins server.
After enter your right credentials, you will be redirect to the jenkins server.
Keep in mind that jenkins container already has the jenkins user
. So you can clone any repository through this user. For that purpose, we are going to create our SSH keys inside the container:
- Enter to the jenkins repository:
docker exec -i -t nginxproject_jenkinsservice_1 bash
- Into the container, place into the JENKINS_HOME path (/var/jenkins_home) and try to clone your own repository with SSH, for instance:
git clone git@bitbucket.org:orbisunt/YOU_REPO.git
- You will be prompted like this:
The authenticity of host 'bitbucket.org (...)' can't be established.
RSA key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no)?
-
Write
yes
and tap enter, the.ssh
folder will be created automatically and the bitbucket server host will be added into the known_hosts file (/var/jenkins_home/.ssh/known_hosts) -
Until this point, we can't clone our repository with SSH because we haven't created our SSH KEYS(private and public) yet. For that purpose, we need to run:
ssh-keygen
- Press enter and we'll have our private and public keys, something like this:
cd /var/jenkins_home/.ssh ; ls
id_rsa id_rsa.pub known_hosts
- Go to Bitbucket -> bitbucket settings -> SSH Keys.
- Copy the content of your id_rsa.pub and add it.
cat /var/jenkins_home/.ssh/id_rsa.pub
- Once your bitbucket repository already has your public key, try to clone your repository with ssh again:
git clone git@bitbucket.org:orbisunt/YOU_REPO.git
- This time you will be able to clone your repository.
- Happy coding!!!!
When it comes to Android UI Tests, the best way is to run tests in a separate host machine. For that purpose, to take advantage of the speed of emulators in your host machine(MacOSX, Linux, Windows). We are going to create a Jenkins Slave Node.
- Go to Manage Jenkins > Manage Nodes.
- Enter Node Name. For example "android".
- Select Permanent Agent and press OK.
- Number of executors. For example 1.
- Set a Remote FS Root. For example "/Users/carlitosdroid/slave"
- Launch Method > Launch slave agents via Java Web Start
- That's all. Press Save and Go back to Nodes.
- Connect slave to jenkins from terminal run the following:
java -jar agent.jar -jnlpUrl http://localhost/jenkins/computer/android/slave-agent.jnlp -secret 636e4c1230031230536a46a3fc8f782fa123ea56477fb3f3226c06fcdcf09dd6 -workDir "/Users/carlitosdroid/slave" -auth YOUR_USER_NAME:YOUR_PASSWORD
All the steps above are here: Step by step guide to set up master and slave machines on Windows
If you wish, you can download these additional libraries for building your app:
cd $ANDROID_HOME/tools/bin/ && ./sdkmanager "extras;google;m2repository" "platforms;android-27" \
"extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2" \
"extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2" \
"cmake;3.6.4111459" "ndk-bundle"
ERROR: Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first. SOLUTION: Add fastlane/report.xml code line to your .gitignore file
ERROR: WARN - Crashlytics had a problem uploading the distribution. Project is inactive SOLUTION: Imeplementing crashlytic correctly in your project and generate a crash to active the app in crashlytics darshboard.
Make the server port is available, usually the default available por is 80