How to do installation and configuration of GoCD on CentOS? – Part 1

Configure-GoCD-with-Let-s-Encrypt-SSL-certificate-on-ubuntu-16.04-1

Let’s do installation and configuration of GoCD

GoCD is an open source system. GoCD is continuous delivery and automation system. GoCD helps you to streamline and automate your BTR (build, test and release) cycle for perfect and continuous delivery of the product. With the help of its sequential and parallel execution, it configures the dependencies for on demand deployment and faster feedback. You can model complex workflows easily. You can visualize a complex workflow end to end in real-time by using its value stream map.

GoCD compares two builds and let you deploy the version of your choice. GoCD executes tests in various frameworks and languages. It provides cross-platform and parallel execution. GoCD reporting tells you the exact changeset and where the test broke which helps in debugging and fixing. There are various plugins and extensions available, you can use them. You can also create your own plugin.

GoCD does not restrict its installation to any specific operating system (OS). You can use any operating system (OS) of your choice; however, the installation steps would vary according to the choice of operating system.

In this first part of this tutorial, you will learn about prerequisites for GoCD, hardware configurations recommended for GoCD, how to add user, how to assign root privileges to a user, how to update CentOS, how to install epel-release, how to install git, how to install nano-editor, how to install Java and how to do security group settings necessary for GoCD server.

Prerequisites:

    1. VPS must have at least 1GB RAM and 2 Core processor.
    2. You should setup your VPS’s hostname.
    3. A registered domain name

Getting started:

  1. After completing the prerequisites, login as root user with your root username & password via SSH client (e.g. Putty – You can get Putty from https://www.putty.org )

Add a User with Root Privileges:

In the first step, you will add a new user and give it sudo privileges. Sudo privileges will allow this username to make administrative changes on system when required. This user will be used to login from via SSH for everyday use. Once you have added this user, to keep your server secure from various attacks, you will disable the remote root access to root user.

  1. To create a new user account, use the following command:
# adduser aareez

where “aareez” can be any username of your choice.

  1. Now you will need to set password for your added username. To set password, execute the following commands:
# passwd aareez

Now set your desired password and retype your desired password, then hit Enter key. To confirm the data is correct, type ‘Y’ and hit Enter key.

  1. Now assign username to sudo user’s group to give administrative privileges. For this, we will check /etc/sudoers file and see whether sudoers group is enabled or not. For this purpose, we will execute the following command.
# visudo
  1. After executing the above command, a file will be opened, find the following lines in the opened file.

how to install gocd on server

Sometimes by default the second line %wheel    ALL=(ALL:ALL)    ALL is commented (starting with hash #), due to which even after adding username to sudoers, it gives error on using sudo. To prevent this issue, if this line starts with ‘#’ sign, remove this symbol and save the changes by pressing Esc key, type 😡 and hit enter.

  1. Now you will add your username “aareez” to the “wheel” group by executing the following command:
# usermod -aG wheel aareez

After execution of the above command, you can verify the membership for that group by executing the following command:

# groups aareez

Your username has been successfully added to sudoers group and it is able to execute any root command.

  1. Now, log in by using your new username and password. OR Use the following command to switch user:
# su - aareez

You can see that you have been logged in from your new account now. If you want to verify this, you can use the command below:

# whoami

 

Update CentOS 7 System:

Before proceeding with installation of any kind of package, use the following command to update your CentOS system. To execute this command, remember to login from non-root user with sudo privileges.

# sudo yum -y update

Now you have successfully updated your CentOS system.

 

Install epel-release:

  1. To install epel-release, execute the command below:
# sudo yum install epel-release
  1. You will be asked “Is it ok?”, to proceed with installation, type ‘y’ and hit Enter
  2. After you have successfully installed epel-release. You will need to update and restart system.
  3. Now to perform the system update, restart your system using the following command.
# sudo yum update -y && sudo shutdown -r now
  1. Now you will need to access your ECS via Putty again after restart has been completed. Remember to use your newly added username with sudo rights to log in to ECS.

 

Install Git:

You will need to install Git to get clone of Let’s Encrypt SSL from Github. To install git, follow the steps below:

  1. Execute the following command:
# sudo yum -y install git

 

Install nano text editor:

You will need to install nano editor to edit files.

  1. Execute the following command:
# sudo yum -y install nano

 

Install Java:

GoCD requires Java version 8. You are allowed to use Oracle Java or OpenJDK. The steps for installation may vary. In this tutorial, I will use Java 8 form OpenJDK because it is already available in yum package by default.

  1. To install the Java version 8, you will need to execute the following command:
# sudo yum -y install java-1.8.0-openjdk-devel
  1. Now you will see that you have successfully install Java.
  2. After installation, you will be able to confirm your Java installation. For that, execute the commands below:
# java -version
  1. Now we will need to setup environment variables for Java that are JRE_HOME and JAVA_HOME. To set environment variables, you will need absolute path of your Java executables. To find absolute path, execute the following command:
# readlink -f $(which java)

You will see the following output.

 

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java

 

  1. Now execute the following commands to set JAVA_HOME and JRE_HOME.
 

# echo “export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64” >> ~/.bash_profile

 

# echo “export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre” >> ~/.bash_profile

 

  1. Now execute the following command to execute the file.
# source ~/.bash_profile
  1. Now execute the following command to ensure whether environment variables have been set correctly.
# echo $JAVA_HOME

 

In this first part of this tutorial, you have learnt about prerequisites for GoCD, hardware configurations recommended for GoCD, how to add user, how to assign root privileges to a user, how to update CentOS, how to install epel-release, how to install git, how to install nano-editor, how to install Java and how to do security group settings necessary for GoCD server. In the next part, you will learn about installation of GoCD and configuration of GoCD along with installation of SSL using Let’s Encrypt. For the next steps to complete installation, you will need to follow steps in part 2. Click here for part 2.

 

Author: Arslan ud Din Shafiq

Alibaba Cloud MVP, Alibaba Cloud Technical Author, Dzone MVB, Software Engineer, Software Developer, Software Designer, Web Engineer, Web Developer, Web Designer, Database Designer, Database Developer, Cloud Computing Specialist, Linux Expert, Servers, 3D Modeling, Blogger, Facebook Map Editor, Google Map Editor

1 thought on “How to do installation and configuration of GoCD on CentOS? – Part 1

Leave a Reply

Your email address will not be published. Required fields are marked *