Skip to main content

Move Jenkins from default directory to another directory


Main requirement of moving jenkins from root is that "root" always have lesser space captured in cloud platforms and "ebs" will be attached to provide more space to the node.

By default when you install jenkins on any linux machines(centos/ubuntu etc...) Jenkins will be placed under /var/lib/jenkins with owner & group ownership of "jenkins" user.

When we want to move jenkins from "root"(which is not having sufficient space) to /ebs(elastic block storage of any cloud CAAS), just follow below steps:

The example im taking here is I will be moving jenkins from "/var/lib/jenkins" to "/ebs/jenkins"

1. firstly stop the jenkins running by "sudo service jenkins stop"

2. copy all the contents of jenkins folder from "/var/lib/jenkins" to "/ebs/jenkins" by -
sudo cp -r /var/lib/jenkins /ebs/

3. now come to /ebs by "cd /ebs" and check the owner & group of jenkins folder under /ebs, now it will be your username instead of jenkins, we need to assign jenkins as both owner & group for all files inside jenkins directory by-
sudo chown -R jenkins:jenkins /ebs/jenkins <this will assign jenkins for all the files recursively>

4. now we need to change the new path of jenkins on "sudo /etc/passwd" file.
inside this file you will find a line starting with "jenkins" on end of teh line just change the content from "/var/lib/jenkins" to "/ebs/jenkins" and save file by ":x".

5. On bashrc we need to create JENKINS_HOME var with new path and assign it to path by-
vi ~/.bashrc

JENKINS_HOME=/ebs/jenkins
PATH=/sbin:/bin/java:$JENKINS_HOME

now save the bashrc file by ":x".
to execute this bashrc file run "source ~/.bashrc" which is mandatory that it will update all newly saved vars.

6. now open the main script of jenkins (sudo vi /etc/init.d/jenkins) which will be used when starting/stopping/restarting jenkins and change the content from  "JENKINS_HOME" to "/ebs/jenkins" and save file by ":x".

7. Now run the command "sudo systemctl daemon-reload" which will reload all the new setting done to jenkins configuration file.

8. now time to restart jenkins by "sudo service jenkins start".

9. open the jenkins on browser with 8080 port to access newly changed path.
to verify whether jenkins is running on newly changed path run "ps -ef|grep jenkins"
on the results it gives, verify -DJENKINS_HOME= value (it should be now "/ebs/jenkins").

Comments

Popular posts from this blog

javamail jdk11(11.0.10 and above) needs tls upgrade from 1.1 to 1.2

ISSUE 1: Unable to send/read mails using javamail/javaxmail after you upgraded your jdk to 11.0.10 or above?  The reason is they came up with higher security level for SSL with TLS 1.2 which is dependency for latest jdk, find the solution below: Possible Exception if you used older version TLS-1.1:  javax.net.ssl.sslhandshakeexception Solution: Add below property to your existing Properties. properties.put("mail.imaps.ssl.protocols","TLSv1.2");(IMAP used to read mail) properties.put("mail.smtp.ssl.protocols","TLSv1.2");(SMTP used to send mail) ISSUE 2: Unable to type case Multipart to String? From jdk11(latest version) onwards multipart and string cant be type casted, so we need to use Object to store message content. Solution: for (int i = 0; i < messages.length; i++) { Message message = messages[i]; Object content = message.getContent(); if (content instanceof String) { String body = (String)content; System.out.println...

Extent report for Rest API test

Below code helps in failing or passing your Rest API test case & updating result to Extent report. Maven dependency(pom.xml): <dependency>     <groupId>com.aventstack</groupId>     <artifactId>extentreports</artifactId>     <version>4.0.9</version> </dependency> code: import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.reporter.ExtentHtmlReporter; import com.aventstack.extentreports.reporter.ExtentLoggerReporter; public class A{ ExtentLoggerReporter logger = new ExtentLoggerReporter("dir path to store extent result"); static ExtentReports extent; @Test public void testname(){ //Your code to capture json from get/post/put/delete API to "JSONObject jsonobjexpected" field. //your code to read actual json content from file/anywhere to "JSONObject jsonobjactual" field. try {         JSONAssert.assertEquals(jsonobjexpected.toString(...

RestAssured rest API test framework for GET & POST API json verification with Extent report

package com.resttest; import static io.restassured.RestAssured.given; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.sql.DriverManager; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Pattern; import org.apache.commons.collections.iterators.EntrySetMapIterator; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.json.JSONException; import org.json.JSONObject; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import org.testng.Assert; import org.testng.TestNG; import org.testng.annotations.AfterTest; import org.testn...