DEV Community

Janak Shrestha
Janak Shrestha

Posted on

Configure Jenkins Job for Package Installation

Some new requirements have come up to install and configure some packages on the Nautilus infrastructure under Stratos Datacenter. The Nautilus DevOps team installed and configured a new Jenkins server so they wanted to create a Jenkins job to automate this task. Find below more details and complete the task accordingly:

  1. Access the Jenkins UI by clicking on the Jenkins button in the top bar. Log in using the credentials: username admin and password Adm!n321.

  2. Create a new Jenkins job named install-packages and configure it with the following specifications:

Add a string parameter named PACKAGE.

Configure the job to install a package specified in the $PACKAGE parameter on the storage server (Stratos Datacenter).

Build the job at least once (e.g. with parameter PACKAGE=vim-enhanced) so the package is installed on the Storage server and can be verified.

Note:

  1. Ensure to install any required plugins and restart the Jenkins service if necessary. Opt for Restart Jenkins when installation is complete and no jobs are running on the plugin installation/update page. Refresh the UI page if needed after restarting the service.

  2. Verify that the Jenkins job runs successfully on repeated executions to ensure reliability.

  3. Capture screenshots of your configuration for documentation and review purposes. Alternatively, use screen recording software like loom.com for comprehensive documentation and sharing.


Step 1: Access Jenkins UI

Click the Jenkins button in the top bar and log in with:

  • Username: admin
  • Password: Adm!n321

Step 2: Install Required Plugin

The Publish Over SSH plugin is recommended for this task, as it allows Jenkins to execute commands on remote servers directly .

  1. Go to Manage JenkinsPluginsAvailable
  2. Search for "Publish Over SSH"
  3. Check the box and click Install without restart
  4. If prompted, select "Restart Jenkins when installation is complete and no jobs are running"

Refresh the UI page after Jenkins restarts.

Step 3: Configure SSH Connection to Storage Server

Before creating the job, you need to set up SSH connectivity from Jenkins to ststor01:

  1. Go to Manage JenkinsConfigure System
  2. Scroll down to Publish over SSH section
  3. Click Add to create a new SSH server
  4. Configure with these details:
    • Name: ststor01
    • Hostname: ststor01
    • Username: natasha
    • Remote Directory: /home/natasha (or leave blank)
    • Password: Bl@kW (or use key-based authentication)
  5. Click Test Configuration to verify connectivity
  6. Click Save

Step 4: Create the install-packages Job

  1. From the dashboard, click New Item
  2. Enter name: install-packages
  3. Select Freestyle project
  4. Click OK

Step 5: Add the PACKAGE Parameter

  1. In the job configuration, scroll to General
  2. Check "This project is parameterized"
  3. Click Add Parameter → select String Parameter
  4. Configure the parameter:
    • Name: PACKAGE
    • Default Value: vim-enhanced (or leave blank)
    • Description: Enter the package name to install on the storage server
  5. Click Save

Step 6: Configure Build Step to Install Package

  1. Scroll down to the Build section
  2. Click Add build step → select Send files or execute commands over SSH
  3. Select the server: ststor01
  4. In the Exec command field, add:
sudo yum install -y $PACKAGE || sudo apt-get install -y $PACKAGE
Enter fullscreen mode Exit fullscreen mode

Important: The natasha user needs passwordless sudo access. If you encounter a sudo: sorry, you must have a tty to run sudo error, the Jenkins server admin must add this entry to the sudoers file on ststor01 :

natasha ALL=(ALL) NOPASSWD: ALL
Enter fullscreen mode Exit fullscreen mode

Or alternatively, disable the TTY requirement:

Defaults:natasha !requiretty
Enter fullscreen mode Exit fullscreen mode
  1. Click Save

Step 7: Build the Job

  1. From the job page, click Build with Parameters
  2. Enter a package name, e.g., vim-enhanced
  3. Click Build
  4. Click Console Output to monitor the build progress and verify success

Step 8: Verify Installation

After the build succeeds, SSH into ststor01 and verify:

ssh natasha@ststor01
rpm -qa | grep vim-enhanced    # For RHEL/CentOS
# OR
dpkg -l | grep vim-enhanced    # For Ubuntu/Debian
Enter fullscreen mode Exit fullscreen mode

Step 9: Test Repeated Executions

Run the job again with different packages (e.g., curl, git) to ensure the job works reliably on repeated executions .

Summary

Step Action
1 Log in to Jenkins UI (admin / Adm!n321)
2 Install Publish Over SSH plugin
3 Configure SSH connection to ststor01
4 Create Freestyle job named install-packages
5 Add String Parameter PACKAGE
6 Configure build step with SSH command
7 Build with parameter (e.g., vim-enhanced)
8 Verify installation on storage server
9 Test repeatedly for reliability

Key Points:

  • Use Publish Over SSH plugin for reliable remote execution
  • Ensure natasha has passwordless sudo access on ststor01
  • Test the job multiple times with different packages to ensure reliability

Top comments (0)