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:
Access the Jenkins UI by clicking on the
Jenkinsbutton in the top bar. Log in using the credentials: usernameadminand passwordAdm!n321.Create a new Jenkins job named
install-packagesand configure it with the following specifications:
- Add a string parameter named
PACKAGE. - Configure the job to install a package specified in the
$PACKAGEparameter on thestorage 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:
- 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 runningon the plugin installation/update page. Refresh the UI page if needed after restarting the service. - Verify that the Jenkins job runs successfully on repeated executions to ensure reliability.
- Capture screenshots of your configuration for documentation and review purposes. Alternatively, use screen recording software like
loom.comfor comprehensive documentation and sharing.
Step-by-Step Solution
Step 1: Access Jenkins UI
- Click the Jenkins button on the top bar
- Login with:
-
Username:
admin -
Password:
Adm!n321
-
Username:
Step 2: Install Required Plugin (Publish Over SSH)
- Navigate to Manage Jenkins → Plugins
- Click on Available plugins
- Search for Publish Over SSH
- Check the box and click Install without restart or Download now and install after restart
- Optionally select Restart Jenkins when installation is complete and no jobs are running
Step 3: Configure SSH Credentials for Storage Server
Option A: Using Publish Over SSH Plugin (Recommended)
- Go to Manage Jenkins → Configure System
- Scroll to Publish over SSH section
- Click Add next to SSH Servers
- Configure:
-
Name:
storage-server -
Hostname:
ststor01.stratos.xfusioncorp.com -
Username:
natasha -
Remote Directory:
/tmp
-
Name:
- Under Advanced, check Use password authentication
- Enter the password:
Bl@kW - Click Test Configuration to verify
- Click Save
Option B: Configure Passwordless SSH (Alternative)
On the Jenkins server:
# Generate SSH key
ssh-keygen -t rsa -b 4096 -N ""
# Copy public key to storage server
ssh-copy-id natasha@ststor01
On the Storage server:
# Add sudoers entry for passwordless sudo
sudo visudo
# Add:
natasha ALL=(ALL) NOPASSWD: ALL
Step 4: Create the Jenkins Job
- From the Jenkins dashboard, click New Item
- Enter job name:
install-packages - Select Freestyle project
- Click OK
Step 5: Configure Job Parameters
- Under General, check This project is parameterized
- Click Add Parameter → String Parameter
- Configure:
-
Name:
PACKAGE -
Default Value:
vim-enhanced(or leave blank) - Description: Enter the package name to install on the storage server
-
Name:
- Click Save
Step 6: Configure Build Step (Using Publish Over SSH)
- Scroll to Build section
- Click Add build step → Send files or execute commands over SSH
- Configure:
-
Name: Select
storage-server - Exec command:
-
Name: Select
sudo yum install -y $PACKAGE
- Click Save
Step 6 (Alternative): Configure Build Step (Using Shell Script)
If not using the plugin, add a shell build step:
# Install sshpass if not present
which sshpass || sudo apt-get install -y sshpass
# Run the installation
sshpass -p 'Bl@kW' ssh -o StrictHostKeyChecking=no natasha@ststor01 "echo 'Bl@kW' | sudo -S yum install -y $PACKAGE"
Step 7: Build the Job with Parameters
- From the job page, click Build with Parameters
- Enter:
-
PACKAGE:
vim-enhanced
-
PACKAGE:
- Click Build
Step 8: Verify the Build
- Check the Console Output to ensure the installation succeeded
- Verify on the Storage server:
# SSH to storage server
ssh natasha@ststor01
# Verify package is installed
rpm -q vim-enhanced
Complete Job Configuration Summary
| Setting | Value |
|---|---|
| Job Name | install-packages |
| Job Type | Freestyle project |
| Parameter Name | PACKAGE |
| Parameter Type | String Parameter |
| SSH Server | storage-server |
| Build Step | Send files or execute commands over SSH |
| Exec Command | sudo yum install -y $PACKAGE |
Expected Console Output
Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/install-packages
[SSH] script:
sudo yum install -y vim-enhanced
[SSH] executing...
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:8.0.1763-19.el8 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
Installing:
vim-enhanced x86_64 2:8.0.1763-19.el8 base 1.5 M
Installed:
vim-enhanced.x86_64 2:8.0.1763-19.el8
Complete!
[SSH] completed
[SSH] exit-status: 0
Finished: SUCCESS
Verification Commands
# On the Storage server - verify package installation
rpm -q vim-enhanced
# Expected output:
# vim-enhanced-8.0.1763-19.el8.x86_64
Troubleshooting
Issue 1: SSH Connection Failed
Solution: Verify credentials and ensure the storage server is reachable:
ssh natasha@ststor01
Issue 2: sudo Requires Password
Error: sudo: a terminal is required to read the password
Solution: Use -S flag to read password from stdin:
echo 'Bl@kW' | sudo -S yum install -y $PACKAGE
Or add passwordless sudo on the storage server:
sudo visudo
# Add:
natasha ALL=(ALL) NOPASSWD: ALL
Issue 3: Package Already Installed
Solution: The -y flag handles this gracefully. The job will succeed with a message indicating the package is already installed.
Issue 4: Plugin Not Available
Solution: Ensure plugins are installed and Jenkins is restarted:
- Go to Manage Jenkins → Plugins
- Install Publish Over SSH
- Restart Jenkins
Top comments (0)