0% found this document useful (0 votes)
14 views2 pages

4 - Where Jenkins Run The Job With "Execute Shell" Either Launch A New Container or Executes The Shell Commands Directly On Jenkins Machine ?

Jenkins executed the shell commands directly on the machine where it is installed, not in a separate container. It creates a temporary shell script with the commands and runs it in the same environment. Containers are only used if explicitly configured for Docker agents or through a Docker Pipeline step.

Uploaded by

Kashif Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

4 - Where Jenkins Run The Job With "Execute Shell" Either Launch A New Container or Executes The Shell Commands Directly On Jenkins Machine ?

Jenkins executed the shell commands directly on the machine where it is installed, not in a separate container. It creates a temporary shell script with the commands and runs it in the same environment. Containers are only used if explicitly configured for Docker agents or through a Docker Pipeline step.

Uploaded by

Kashif Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Make me understand one concept.

In Jenkins, I created a project named "project2" and select "Execute shell" from Build Steps, then run
following linux commands

ls /etc | grep "pa" > /tmp/files.txt

After running the job, it's output

Started by user admin


Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/project2
[project2] $ /bin/sh -xe /tmp/jenkins18253798557060487816.sh
+ ls /etc
+ grep pa
[project2] $ /bin/sh -xe /tmp/jenkins12074021444464015838.sh
+ cat /tmp/files.txt
pam.conf
pam.d
passwd
passwd-
Finished: SUCCESS

I wanna understand that Jenkins launched new linux container to run these linux commands or it
executed command into Jenkins machine where jenkins running ? clear my concept

Great question! Let’s break it down clearly.

Where Did Jenkins Execute These Commands?

When you run a Jenkins job with "Execute shell", Jenkins does not launch a new
container. Instead, it executes the shell commands directly on the machine where Jenkins
is running.

How It Works?

 Jenkins uses a workspace directory (/var/jenkins_home/workspace/project2 in


your case).
 When you trigger a build, Jenkins creates a temporary shell script (like
/tmp/jenkins18253798557060487816.sh).
 This script contains the Linux commands from the "Execute shell" step.
 Then, Jenkins executes this script in the same environment where Jenkins is
installed (e.g., your Jenkins server or container).

How to Verify?

1. Check the OS where Jenkins is running


oIf Jenkins is running on a Linux host, the commands run on that Linux
machine.
o If Jenkins is running in a Docker container, the commands run inside the
container where Jenkins is running.
2. Run uname -a in Jenkins Shell
o Add this to the "Execute shell" step:

uname -a

o If it prints your Jenkins host machine's OS, then it's running directly on that
machine.
o If Jenkins is inside a container, it will print the container’s OS details.

Did Jenkins Create a New Container?

❌ No, Jenkins did not launch a new container. It executed the script directly on the
Jenkins machine (or the container where Jenkins is running).

When Does Jenkins Use Containers?

Jenkins only uses a separate container if:

1. You configure Jenkins to use Docker agents (e.g., inside a Kubernetes cluster).
2. You explicitly use a Docker Pipeline step to run a command inside a container:

pipeline {
agent { docker 'ubuntu' }
stages {
stage('Build') {
steps {
sh 'ls /etc | grep "pa" > /tmp/files.txt'
}
}
}
}

o In this case, Jenkins spins up a new Ubuntu container and executes


commands inside it.

Final Answer:

✔ Jenkins executed the shell commands directly on the machine where Jenkins is
installed (not in a separate container).

You might also like