Skip to content

Instantly share code, notes, and snippets.

@phackwer
Created November 23, 2016 18:29
Show Gist options
  • Save phackwer/d8de9771aa0b5ae4e22aebd6c87a144d to your computer and use it in GitHub Desktop.
Save phackwer/d8de9771aa0b5ae4e22aebd6c87a144d to your computer and use it in GitHub Desktop.
INSTALL JENKINS IMAGE FOR DOCKER
--------------------------------
Go as root:
$ sudo su
Run the jenkins container for the first time specifying the volume on current filesystem and ports:
# docker run -p 8080:8080 -p 50000:50000 -v /home/phackwer/Projects/jenkins/:/var/jenkins_home jenkins
Write down the admin password (or copy annd paste), you will need it to setup jenkins.
Go to http://localhost:8080 and install the required plugins for the PHP analisys and deployment.
Check the Container ID running the command
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d0db6f994cc7 jenkins "/bin/tini -- /usr/lo" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp elegant_northcutt
8189df2752ab sonarqube "./bin/run.sh" 5 hours ago Up 5 hours 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp sonarqube
The Container ID in this case is d0db6f994cc7. We will use it from now on for a lot of operations.
You can get any docker container informations (IPs, etc) running the command:
# docker inspect 4890c0554b8
SETUP JENKINS FOR PHP
---------------------
Login as root on a running docker container:
# docker exec -u 0 -i -t d0db6f994cc7 /bin/bash
On the container, install required ubuntu packages:
# apt-get install -y software-properties-common python-software-properties
Add PHP 7.0 support:
# echo '' >> /etc/apt/sources.list
# echo 'deb http://packages.dotdeb.org jessie all' >> /etc/apt/sources.list
# echo 'deb-src http://packages.dotdeb.org jessie all' >> /etc/apt/sources.list
# apt-get update
# apt-get install -y --force-yes imagemagick libmagickwand-dev libpcre3 libpcre3-dev \
php7.0 php7.0-mcrypt php7.0-mbstring php7.0-dev php7.0-mysql php7.0-odbc \
php7.0-json php7.0-bcmath php7.0-fpm php7.0-gd php7.0-intl \
php7.0-pgsql php7.0-curl php7.0-gd php7.0-sqlite3 php7.0-xml
Add Composer support so you can build your installation package:
# wget https://getcomposer.org/installer
# php installer
# mv composer.phar /usr/bin/composer
INSTALL SONARQUBE IMAGE FOR DOCKER
----------------------------------
As root, run
# docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube
Now login as admin with admin password on http://localhost:9000 and just add the plugin to support the PHP language.
SETUP JENKINS TO USE SONAR
--------------------------
Use the following commands to get the SonarQube IP Address:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d0db6f994cc7 jenkins "/bin/tini -- /usr/lo" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp elegant_northcutt
8189df2752ab sonarqube "./bin/run.sh" 5 hours ago Up 5 hours 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp sonarqube
# docker inspect 8189df2752ab | grep "IPAddress"
Go to the Configure System and add a SonarQube Server pointing to the address you got from the previous command.
Just to be fast, we will say we are using the 5.2 version and inform admin/admin username/password combination.
Now go to Global Tool Configuration and find the SonarQube Scanner section.
Click the SonarQube Scanner Instalations and add one.
Select the Install Autoomatically option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment