User Tools

Site Tools


toolsandtechnologies:jenkins_2_grails_dockerized_testing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
toolsandtechnologies:jenkins_2_grails_dockerized_testing [2019/07/12 08:18] kfantoolsandtechnologies:jenkins_2_grails_dockerized_testing [2021/06/25 10:09] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +===== Jenkins - Grails 2 - Dockerised Testing =====
 +==== Motivation ====
 +
 +As part of [[https://errigal.atlassian.net/browse/IDMS-3778|IDMS-3788]], effort was made to dockerize the jenkins testing pipelines for the **grails** applications (**Ticketer, Reporting Manager, Noc Portal and Snmp Mananger**) as previously, there was the following problems:
 +  * These pipelines did not allow for concurrent builds due to using the same grails instances 
 +    * Current builds would fail at any grails stage if another build from another branch starts
 +  * Tests were also polluted for the same reason if there were multiple builds on going. 
 +
 +This severely decreases the productivity and use of jenkins builds of these applications due to:
 +  * Devs need to wait for on-going builds to be completed before starting their own 
 +  * Important builds could fail if another dev pushed their changes and an automatic build was done
 +    * Dev need to send out notices to prevent people from pushing changes + keep watch / kill any builds 
 +
 +
 +To resolve this, docker was installed onto the jenkins server (currently **calliope.err** at the time of writing) and the respective grails project jenkins file was updated to use custom docker grails images for use in the pipeline stages of these projects during build.
 +
 +==== Custom Grails Docker Images Project ====
 +
 +Custom docker images were built in the server via [[https://bitbucket.org/errigal/jenkins_docker_images/src/master/|jenkins_docker_images]] project for use in jenkins pipelines of the grails application. Custom images were used instead of publicly available images as it would allow control of defining java versions and grails versions per docker image in use.
 +
 +This project allows for deploying templated Dockerfiles and building the docker images for use in the server. It also allow for removing the images. 
 +
 +==== Jenkins Pipeline Differences =====
 +The main difference was specifying the use of docker images and passing the necessary arguments to help the download/caching of dependencies and any necessary hosts such as artifactory. In addition, in was necessary to specify the java home of the docker image, as the java home of the jenkins server was somehow used if this wasn't defined 
 +
 +  agent {
 +    docker {
 +      image 'jenkins/grails_ticketer'
 +      args "-v ${GRAILS_CACHE_HOME}:/home/scotty/.grails --add-host errigalArtifactory:${defaults['artifactoryIp']}"
 +    }
 +  }
 +  
 +  environment {
 +    GRAILS_OPTS = "-Xms1024m -Xmx4096m -XX:PermSize=256m -XX:MaxPermSize=1024m"
 +    JAVA_HOME = "/docker-java-home"
 +  }
 +
 +The defaults values for the artifactoryIp and GRAILS_CACHE_HOME were put into the [[https://bitbucket.org/errigal/jenkins-common/src/master/vars/common.groovy|jenkins_commons]] project, as these do not change often and should be constant among the grails projects.
 +
 +==== Sample Templated Variables ====
 +
 +Required templates params are passed via the [[https://bitbucket.org/errigal/env-configuration/src/master/infra/group_vars/all|env-configuration]] (infra) project. An example of params used for the templating and deployment is shown below. 
 +
 +  jenkins_dockerfile_home_path: /home/scotty/docker
 +  jenkins_docker_grails_apps:
 +    - name: Ticketer
 +      java: 7
 +      grails: 2.2.4
 +      tag: jenkins/grails_ticketer
 +    - name: NocPortal
 +      java: 7
 +      grails: 2.2.4
 +      tag: jenkins/grails_noc_portal
 +    - name: SnmpManager
 +      java: 7
 +      grails: 2.5.6
 +      tag: jenkins/grails_snmp_manager
 +    - name: ReportingManager
 +      java: 7
 +      grails: 2.2.4
 +      tag: jenkins/grails_reporting_manager
 +
 +==== Ansible Commands ====
 +For the ansible commands for the creation and removal of the docker images, please see the readme of the [[https://bitbucket.org/errigal/jenkins_docker_images/src/master/|jenkins_docker_images]] project.