User Tools

Site Tools


Writing /app/www/public/data/meta/toolsandtechnologies/jenkins_2_grails_dockerized_testing.meta failed
toolsandtechnologies:jenkins_2_grails_dockerized_testing

Jenkins - Grails 2 - Dockerised Testing

Motivation

As part of 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 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 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 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 jenkins_docker_images project.

toolsandtechnologies/jenkins_2_grails_dockerized_testing.txt · Last modified: 2021/06/25 10:09 by 127.0.0.1