-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkins01
More file actions
47 lines (45 loc) · 1.32 KB
/
Copy pathjenkins01
File metadata and controls
47 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
pipeline {
agent {
label 'slave' // Runs only on agents labeled as 'linux'
}
environment {
DOCKER_HUB_CREDENTIALS = 'docker-hub' // Replace with your credentials ID
DOCKER_IMAGE_NAME = 'alzoghby/test-app' // Replace with your Docker Hub repository name
}
tools {
nodejs 'nodejs23.5' // Ensure NodeJS is configured in Global Tool Configuration
}
stages {
stage('Checkout Code') {
steps {
git branch: 'main', url: 'https://github.com/alzoghby/chat-app.git' // Replace with your repo
}
}
stage('Install Dependencies') {
steps {
sh 'npm install'
}
}
stage('Build Docker Image') {
steps {
script {
docker.build("${DOCKER_IMAGE_NAME}:2.0")
}
}
}
stage('Push Docker Image to Docker Hub') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', DOCKER_HUB_CREDENTIALS) {
docker.image("${DOCKER_IMAGE_NAME}:2.0").push()
}
}
}
}
}
post {
always {
cleanWs()
}
}
}