All technological notes.
Jenkins agent
Jenkins controller to execute build, test, and deployment jobs| Agent Type | Description |
|---|---|
| Built-in agent | Runs jobs directly on the Jenkins controller itself Jenkins controller runs jobs locally |
| Static agent | A fixed VM, physical server, or long-running machine connected to Jenkins |
| Dynamic agent | An agent created on demand when a job starts and removed after the job finishes |
-v /var/run/docker.sock:/var/run/docker.sockdocker network create jenkins-net
# connect jenkins
docker network connect jenkins-net jenkins


docker run -d \
--name jenkins-agent \
--network jenkins-net \
-e JENKINS_URL=http://jenkins:8080/ \
-e JENKINS_AGENT_NAME=docker-agent \
-e JENKINS_SECRET=<secret> \
-v jenkins-agent-work:/home/jenkins/agent \
jenkins/inbound-agent
pipeline {
agent { label 'docker' }
stages {
stage('Hello') {
steps {
sh 'echo Hello World from agent'
sh 'hostname'
}
}
}
}

-v /var/run/docker.sock:/var/run/docker.sockproduction standard
pipeline {
agent {
docker {
image 'node:18'
}
}
stages {
stage('Build') {
steps {
sh 'node -v'
sh 'npm install'
}
}
}
}
pipeline {
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: node
image: node:18
command:
- cat
tty: true
"""
}
}
stages {
stage('Build') {
steps {
container('node') {
sh 'node -v'
}
}
}
}
}