Friday 28 October 2016

Version Control - 08.02 GIT-ADD

Do you have multiple modifications or additions to your repository?

Facing trouble to track those?

Thinking to have individual commits?

Are you again thinking it is painful to have those multiple commits?

Below is the script which can make this painful issue fixed.

 #!/bin/bash  
   
 # GIT Alias to status  
 git config --global alias.s "status -s"  
   
 A=`git s | grep '^A\|^AM\|^AR\|^AD^ A' | awk '{print $2}'`  
 U=`git s | grep ^? | awk '{print $2}'`  
 M=`git s | grep '^M\|^MA\|^MR\|^MM\|^MD\|^ M' | awk '{print $2}'`  
 R=`git s | grep '^R\|^RA\|^RM\|^RR\|^RD\|^ R' | awk '{print $4}'`  
 D=`git s | grep '^D\|^ D' | awk '{print $2}'`  
   
 function add {  
      for i in `echo $A`  
      do  
           git add $i  
           git commit -m "Added $i"  
      done  
 }  
   
 function stgnew {  
      for i in `echo $U`  
      do  
           git add $i  
           git commit -m "Added $i"  
      done  
 }  
   
 function modify {  
      for i in `echo $M`  
      do  
           git add $i  
           git commit -m "Modified $i"  
      done  
 }  
   
 function rename {  
      for i in `echo $R`  
      do  
           R1=`git s | grep $i | awk '{print $2}'`  
           R2=`git s | grep $i | awk '{print $4}'`  
           git add $R2  
           git commit -m "Renamed/Moved $R1 to $R2"  
      done  
 }  
   
 function delete {  
      for i in `echo $D`  
      do  
 #          git add $i  
           git commit -m "Removed $i"  
      done  
 }  
   
 if [[ -z $(git s) ]]  
 then  
      echo "There are neither additions nor deletions to stage"  
 else  
      for i in A U M R D  
      do  
           case $i in  
           A)  
                add  
           ;;  
           U)  
                stgnew  
           ;;  
           M)  
                modify  
           ;;  
           R)  
                rename  
           ;;  
           D)  
                delete  
           ;;  
           esac  
      done  
      git push -fu origin master  
 fi  
   
 # END  

Sunday 16 October 2016

CI-CD_001-Jenkins-Installation

Installation process of Jenkins

  • Download and install latest version of JDK (Java 7 or newer version is recomended)
  • Add the Jenkins repository to the yum repos, and install Jenkins from here.
    $ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
    $ sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
    $ sudo yum install jenkins
  • Turn jenkins service at startup and restart the service
    # chkconfig jenkins on
    # service jenkins start
  • Open your browser and hit the below URL to open Jenkins UI
    http://localhost:8080/
  • It will now prompt for the Initial Admin password which is available in the below file
    /var/lib/jenkins/secrets/initialAdminPassword
Copy that password and paste in the field in the Jenkins web UI
  • Now it will prompt for the installation of Jenkins Plugins. Go for the default.
  • You are all set and the final step is that you need to create a Jenkins user.