Use of uninitialized value $u in substitution (s///) at /usr/share/perl5/Git/SVN.pm line 101

When I try to migrate SVN repository to GIT repository , I was getting the below error.

Use of uninitialized value $u in substitution (s///) at /usr/share/perl5/Git/SVN.pm line 101

Open the file /usr/share/perl5/Git/SVN.pm and go to line 101.

$u =~ s!^\Q$url\E(/|$)!! or die 
        "$refname: '$url' not found in '$u'\n"; 

to this: 

if(!$u) { 
        $u = $pathname; 
}else { 
        $u =~ s!^\Q$url\E(/|$)!! or die 
        "$refname: '$url' not found in '$u'\n"; 
}
Advertisements

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

 

GitLab Spring-Boot Heroku Continuous Integration and Deployment – part 1

Gitlab has in built pipeline for continuous integration and deployment. For every commit to the master branch , Gitlab CI will build and deploy my code to two(dev and staging) different Environments.

Prerequisites 

  1. Gitlab free account https://gitlab.com/
  2. Heroku free account https://www.heroku.com

 

Below is the .gitlab-ci.yml I use to build and deploy the application dev and staging environments

before_script:
 - echo "Execute scripts which are required to bootstrap the application. !"

after_script:
 - echo "Clean up activity can be done here !."
 
cache:
 paths:
 - /root/.m2/repository
 
stages:
 - build
 - deploy

build:
 stage: build
 image: maven:3.3.9-jdk-8
 script:
 - mvn clean package
 tags:
 - docker
 
deploy_dev:
 stage: deploy
 image: ruby:2.3
 script:
 - apt-get update -qy
 - apt-get install -y ruby-dev
 - gem install dpl
 - dpl --provider=heroku --app=vel-ci-api-dev --api-key=$HEROKU_API_KEY
 environment:
 name: dev
 url: https://vel-ci-api-dev.herokuapp.com
 only:
 - master
 tags:
 - docker
 
deploy_staging:
 stage: deploy
 image: ruby:2.3
 script:
 - apt-get update -qy
 - apt-get install -y ruby-dev
 - gem install dpl
 - dpl --provider=heroku --app=vel-ci-api-stg --api-key=$HEROKU_API_KEY
 environment:
 name: staging
 url: https://vel-ci-api-stg.herokuapp.com
 only:
 - master
 tags:
 - docker

I have two stages , build and deploy

build stage has only one job – build

deploy stage has two jobs – deploy_dev , deploy_staging

pipe-line-success

Pipeline-stages-builds

All the jobs in the same stage will be run parallel.

Below are the environments it gets deployed the application.

environments

Environments

 

Application URL’s

https://vel-ci-api-dev.herokuapp.com — Dev Environment.

https://vel-ci-api-stg.herokuapp.com/ — Staging Environment.

 

 

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

How to Daemonize a Java Program?

I have a Java program that I’d like to daemonize on a linux system.
In other words, I want to start running it in a shell and have it continue running after I’ve logged out.
Even After I reboot my system, my java program should be up and running like any other daemon service (sshd etc..)
I also want to be able to stop the program cleanly.

What’s your preferred method to daemonize a Java program on a Linux system?

I have Java Archive (vm.jar) , I want to run this Jar as an UNIX Service. Here are steps I followed to achieve that

  1. Install daemon tools from the URL  https://cr.yp.to/daemontools/install.html  and follow the instruction mentioned there,for any issues please try instructions  error.h
  2. Create a file at /etc/init/svscan.conf and add the below lines.(only required for cent-os-6.7)

start on runlevel [12345]
stop on runlevel [^12345]
respawn
exec /command/svscanboot

3. Create a new script named run inside /service/vm/ folder and add the below lines.

#!/bin/bash
echo starting VM
exec java -jar /root/learning-/daemon-java/vm.jar

 Note:
replace the Jar with your own Jar file. or any java class file.

4. Reboot the system

5. svstat /service/vm should be up and running now !.

6. svc -d /service/vm should bring vm down now !.

7. svc -u /service/vm should bring vm up now !.

Enable eth0 centos-6.7

I have created a VM in virtual box using Centos-6.7. I have configured eth0 interface as bridge adapter. However I am not able to connect to internet. When I did ifconfig , I could only see loopback address as shown below.

ifconfig

ifconfig – displays the connected network interfaces.

ip link displays the available network interfaces on machine.

ip-link

ip-link – displays the available network interfaces

 

  1. add NETWORKING=yes in /etc/sysconfig/network file.
  2. create a new file called ifcfg-eth0 in /etc/sysconfig/network-scripts/ folder as shown below. ifcfg-eth0DEVICE=eth0
    BOOTPROTO=dhcp
    ONBOOT=yes
  3. save and reboot the machine.
  4. Now you should be able to see the eth0 network in ifconfigifconfig-eth0

ifup eth0 will throw an below error  “Configuration for eth0 not found “ unless we create a file in /etc/sysconfig/network-scripts/ifcfg-eth0 no-device-found

ifup eth0 throws “Device eth0 does not seem to be present, delaying initialization.”

rm -f /etc/udev/rules.d/70-persistent-net.rules  

restart