GitLab Spring-Boot Heroku Continuous Integration and Deployment – part 2 (Review Apps)

In the previous post Gitlab-CI-Spring-Boot-Heroku-Continuous-integration-and-Deployment/, Every commit to master branch , Gitlab CI will build and deploy the application to two different environments (dev and stage). This is great. How about creating a new dynamic environment for every new merge request (branch) ? . The Repository owner can review the merge request and provide you the immediate feedback. Yes ! That is called “Review Apps” Review Apps

Objective:

  • Developers create a new branch “feature-xyz” and start implementing the features which he is supposed to complete as part of the Agile development process.
  • Developers commits the code, test it locally before pushing the branch to remote repository.
  • As soon as the branch (feature-xyz) is pushed to repository, Gitlab CI will trigger the pipeline ,which will deploy the feature branches into a  new dynamic environment.
merge-request-environment

Merge Request Environment

When a merge request is created , the corresponding dynamic environment is shown in the page as shown above.

dynamic environments

All the dynamic environments are grouped under review

environments-review

All the deployed environments are grouped under “Review”

As I have four feature branches in my repository , four environments get deployed by Gitlab CI. Each dynamic environment will be deleted once the corresponding branch is deleted. It can also be stopped manually from the Gitlab UI.

 

The complete gitlab-ci.yml is shown below.

Review : Responsible for creating a new environment for every new branch

Stop_Review : Responsible for deleting the environment whenever the branch is deleted or manually stopped from Gitlab UI.

Gitlab Source Code of this repo

 

InitializationError java.lang.IllegalStateException: Failed to transform class with name Processor.java. Reason: java.io.IOException: invalid constant type: 18

When we upgraded our application to jdk-8 , I was getting the below error during my gradle test task.

initializationError java.lang.IllegalStateException: Failed to transform class with name Processor.java. Reason: java.io.IOException: invalid constant type: 18

The issue was one of my class was using javasssit library which is not compatible with java-8. So we have upgraded javassist to the latest version.

 

compile(group: ‘org.javassist’, name: ‘javassist’, version: ‘3.20.0-GA’)

Reference:

https://github.com/brettwooldridge/HikariCP/issues/83

https://github.com/bitronix/btm/issues/38

 

 

 

steps to upgrade jdk-8 & gradle-2.11

Upgrading java using update-alternatives


  1. Download the latest java-8 binary zip from official oracle downloads
  2. Create a new folder  under /opt
     mkdir -p /opt/jdk-8
  3. Extract the gzip file to the /opt/jdk-8 directory
     tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk-8
  4. Setting Oracle JDK as the default JVM
    update-alternatives --install /usr/bin/java java  /opt/jdk-8/jdk1.8.0_74/bin/java 2000
    update-alternatives --install /usr/bin/javac  javac /opt/jdk-8/jdk1.8.0_74/bin/javac 2000
  5. Configure java if more than one java version is available already.
     update-alternatives --config java

    choose the correct number if prompted .

  6.  Verify the installation
     java –version

Upgrading gradle manually.


  1. Download the latest gradle binary file from gradle-2.11-all.zip
  2. Create a new folder  under /opt
     mkdir -p /opt/gradle-2.11
  3. Extract the gzip file to the /opt/gradle-2.11 directory
     tar -zxf gradle-2.11.all.zip -C /opt/gradle-2.11
  4. Create a symbolic link to the original file.
     ln -s /opt/gradle-2.11/bin/gradle /usr/local/bin/gradle
  5. Verify the installation
     gradle –version

Note:
gradle –version -> may still use the older version of java  if  JAVA_HOME is not  points to the latest jdk-8 directory.

 export JAVA_HOME=/opt/jdk-8/jdk1.8.0_74
 export PATH=$PATH:$JAVA_HOME/bin

reference:
https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps