Step 1: Provision an Oracle Linux Instance

  • Objective: Create an Oracle Linux compute instance on Oracle Cloud Infrastructure (OCI), which will serve as the server for both Jenkins and your Next.js application.
  • Detailed Steps:
    1. Log in to OCI: Access your Oracle Cloud account through the OCI console.
    2. Create an Instance:
      • Navigate to the Compute section.
      • Click on Instances and then on Create Instance.
      • Choose Oracle Linux as the operating system.
      • Select an appropriate shape (the combination of CPU, memory, and other resources).
      • Configure your networking settings, including VCN (Virtual Cloud Network), subnet, and public IP.
    • Important Configuration:
      • Public IP: Ensure your instance has a public IP address if you need to access it from outside the Oracle Cloud environment.
      • Security Lists: You may need to open ports like 22 (SSH), 8080 (Jenkins), and 3000 (Next.js) in your security lists or network security groups.

Step 2: Update the System

Ensure that your Oracle Linux instance has the latest security patches and software updates.

sudo yum update -y
  • Explanation:
    • sudo: Runs the command with superuser (root) privileges. This is necessary because system updates require administrative access.
    • yum: The default package manager for Oracle Linux, used to install, update, and remove software packages.
    • update: This command updates all the installed packages to their latest versions.
    • y: Automatically answers "yes" to any prompts during the update process.

Step 3: Install Java (OpenJDK)

Install the Java Development Kit (JDK) required to run Jenkins.

sudo yum install java-11-openjdk-devel -y
  • Explanation:
    • sudo: Runs the command with superuser privileges.
    • yum install: Installs a specified package or group of packages.
    • java-11-openjdk-devel: Specifies the OpenJDK 11 Development Kit, which includes the Java Runtime Environment (JRE) and additional tools for Java development.
    • y: Automatically answers "yes" to any prompts during the installation process.

Verify the Java installation:

java -version

Step 4: Install Jenkins

To install the latest stable version of Jenkins, add its repository:

1. Add Jenkins GPG key:

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null

2. Add the Jenkins repository to your system:

echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
  1. Update the package index and install Jenkins:
sudo apt update
sudo apt install jenkins -y
  1. Start and Enable Jenkins Service
sudo systemctl start jenkins
sudo systemctl enable jenkins
  1. Configure Firewall

Allow Jenkins to communicate on port 8080:

sudo ufw allow 8080
sudo ufw reload

Now you can access Jenkins by visiting:

http://your_server_ip_or_domain:8080

Step 5: Access Jenkins

Access the Jenkins web interface to complete the initial setup.

  • Steps: Open the Jenkins Interface:
  1. Open a web browser and go to http://yourinstance-ip-or-domain:8080
  2. Replace yourinstance-ip-or-domain with the actual public IP address of your instance.
  3. cat: Displays the contents of a file.
  4. /var/lib/jenkins/secrets/initialAdminPassword: The file that contains the initial admin password required to unlock Jenkins.

Retrieve the Initial Admin Password:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Step 6: Complete the Setup

Follow the on-screen instructions to:

  1. Install recommended plugins.

Select Install Suggested plugins--

  1. Create an admin user:

After the plugin setup is complete, Jenkins will prompt you to create an administrator user. Fill in the details in the respective fields and click on Save and Finish. Take a look at this screenshot:

s

Now Jenkins will be fully operational on your ubuntu machine and can only be accessed through valid credentials.