Friday, January 27, 2017

Continuous Quality - SonarQube Configuration in Jenkins

DevOps - Continuous Integration : SonarQube Configuration in Jenkins


Install SonarQube in CI server

Download latest SonarQube from https://www.sonarqube.org/downloads and install in your CI server, or for Mac machines brew command can be used alternatively - brew update - brew install sonar ->


Configure & start the sonarQube server

Create sonar database in local server using database queries - CREATE DATABASE sonar_source; - CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar'; - GRANT ALL PRIVILEGES ON sonar_source.* TO 'sonar'@'localhost'; - FLUSH PRIVILEGES; -> Update database details in sonar properties file using command - $ vim /usr/local/Cellar/sonarqube/6.1/libexec/conf/ sonar.properties -> Start the sonar server using command - $ sonar console ->


Configure SonarQube in Jenkins

Install SonarQube plugin in Jenkins using option - Manage Jenkins - Manage Plugins -> Update sonarQube server detail using option - Manage Jenkind - Configure System ->


Create SonarQube build job in Jenkins

Create a maven build job using option - new item -> Check ‘Prepare SonarQube Scanner environment’ under build Environment -> Update pom.xml url in ROOT POM -> Select ‘sonarQube analysis with maven’ under Post-build Actions ->


Run the sonarQube build job & view SonarQube report in Jenkins

Run the build -> Upon successful run, click ‘SonarQube’ icon to view SonarQube code analyzer report.


Monday, January 23, 2017

Continuous Deployment - Puppet master & puppet agent in docker containers

Installing & Running puppet server(master) & puppet agent in docker containers


Create puppet docker containers

Choose a suitable & stable puppet image from dockerhub and install in your docker server -> $ docker pull devopsil/puppet ->


Alternatively, create your own docker file ->


Install a docker container with a suitable puppet master name -> $ Docker run --name puppetmaster -it devopsil/puppet bash -> Install another docker container with a suitable puppet agent name -> $ Docker run --name puppetagent -it devopsil/puppet bash ->

Configure hostname in puppetmaster container with a meaningful name in network file -> # vi etc/sysconfig/network -> HOSTANME=master.demo.com -> Configure hostname in puppetagent container with a meaningful name in network file -> # vi etc/sysconfig/network -> HOSTNAME=agent.demo.com ->

Configure hostname in puppetmaster & puppetagent with same name in hosts file -># vi etc/hosts -> [masterip] 172.17.0.2 master.demo.com -> [agentip] 172.17.0.3 agent.demo.com ->

Ping master form agent and agent from master to test network connection between puppetmaster & puppetagent containers->


Install puppet server & puppet agent in docker containers

Install puppet server in puppetmaster container -># yum install –y puppet puppet-server facter -> install puppet agent in puppetagent container -># yum install –y puppet facter ->


Update puppet.conf file under [main] in puppetmaster container -># vi etc/puppet/puppet.conf -> certname = master.demo.com -> Update puppet.conf file in puppetagent container -># vi etc/puppet/puppet.conf -> server = master.demo.com ->


Start puppet master in puppetmaster container -># service puppetmaster start -># service puppetmaster status ->


Authenticate puppet agent in puppet master

Request certification from agent -># puppet agent --test –server=[master hostname]master.demo.com --waitforcert=50 -> check for certificate request in master -># puppet cert list -> sing certification in master -># puppert cert sign [agent hostname]agent.demo.com ->


Test an example

Create a puppet policy file in puppet master in manifest folder -> # vi etc/puppet/manifest/site.pp ->


Apply the configuration change in puppet agent -># Puppet agent –-test


Thursday, January 12, 2017

Continuous Deployment Automation : Git -> Jenkins -> Docker

DevOps - continuous deployment automation using Git, Jenkins & Docker


Create a Git repository ->


Create a Dockerfile (- to build a container for a php web application shown above in video as an example) inside the Git repository ->


Create other components (index.php under src folder in above example) in the git repository needed to run the designated application inside a docker container -> Change one of these components to git commit the change and trigger a Jenkins build ->


Create a Jenkins freestyle project in Jenkins -> Update the above created Git repository location under SCM configuration of the project -> Select trigger builds remotely and input an authorization token in the configuration ->


Update .git/hooks/post-commit file with a syntax to trigger the Jenkins job created in above step -> Update .git/hooks/post-commit file with a syntax to execute docker commands to create and run a docker container using a Dockerfile ->


Docker commands can be put in an executable file (buildExecutable in this case) ->


Commit the change made (-in one of above steps) in application component -> post-commit of .git/hooks folder will trigger the Jenkins build job -> post-commit will also execute docker commands to build and run a docker container running an application within (a php web application in this case).


Wednesday, January 4, 2017

Continuous Integration Automation : Eclipse -> Selenium -> Git -> Jenkins

DevOps - Continuous Integration Automation using Eclipse, Selenium, Git & Jenkins


Create a maven project in Eclipse -> Create a simple project -> update group ID & artifact ID -> add a package into the project -> add a class into the package->


Update selenium & TestNG dependencies in POM xml file -> Add maven build plugins in POM xml -> Convert the class created in earlier step into a TestNG.xml file -> Save the TestNG.xml file into src/main/resource folder -> Update the location of TestNG file in POM xml under surefire plugin ->


Save the selenium project into a Git repository -> Commit file and folder structure of the project into Git repository -> Make sure Jenkins user have read & write access to this Git repository -> If required clean the repository by running maven clean job with appropriate access ->


Create a maven job in Jenkins -> Update the Git repository url in the job configuration -> Update the location of pom.xml file in job configuration -> Save the maven build job ->


Run the maven build job in Jenkins from Eclipse.