Added Debian Jenkins Agent
This commit is contained in:
52
BuildJenkinsfileAgentDebian
Normal file
52
BuildJenkinsfileAgentDebian
Normal file
@@ -0,0 +1,52 @@
|
||||
// You need a valid credentials for Docker Hub
|
||||
// You need https://plugins.jenkins.io/docker-workflow/ on your jenkins instance
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
node {
|
||||
label 'docker' //Agent needs to have Docker Engine installed
|
||||
}
|
||||
}
|
||||
environment {
|
||||
DOCKER_HUB_USER='guillemhs'
|
||||
IMAGE_NAME="${DOCKER_HUB_USER}/jenkins-debian-13-agent"
|
||||
REGISTRY_CRED_ID='docker-credentials'
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
// Get some code from a GIT repository
|
||||
git branch: 'main', url: 'https://git.agile611.com/Agile611/startusingjenkins.git'
|
||||
}
|
||||
}
|
||||
stage('Docker Build') {
|
||||
steps {
|
||||
script{
|
||||
echo "Build image ..."
|
||||
docker.build("${IMAGE_NAME}:${env.BUILD_NUMBER}","-f DockerfileAgentDebian .")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker Push')
|
||||
{
|
||||
steps{
|
||||
script{
|
||||
docker.withRegistry('',REGISTRY_CRED_ID){
|
||||
def app = docker.image("${IMAGE_NAME}:${env.BUILD_NUMBER}")
|
||||
|
||||
echo "Pushing image to Docker Hub ..."
|
||||
app.push("${env.BUILD_NUMBER}")
|
||||
app.push("latest")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post{
|
||||
always{
|
||||
//cleanWs()
|
||||
sh "docker rmi ${IMAGE_NAME}:${env.BUILD_NUMBER} || true"
|
||||
sh "docker rmi ${IMAGE_NAME}:latest || true"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
DockerfileAgentDebian
Normal file
8
DockerfileAgentDebian
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM debian:13.3-slim
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -y openssh-server openjdk-21-jdk
|
||||
RUN mkdir /var/run/sshd
|
||||
|
||||
RUN useradd -m -d /home/jenkins -s /bin/bash jenkins && echo "jenkins:jenkins" | chpasswd
|
||||
EXPOSE 22
|
||||
CMD ["/usr/sbin/sshd","-D"]
|
||||
Reference in New Issue
Block a user