-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
36 lines (31 loc) · 1.19 KB
/
JenkinsFile
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
node {
// Configura SCM (control de versiones) para Git
stage('Checkout') {
checkout([$class: 'GitSCM', branches: [[name: '*/main']],
userRemoteConfigs: [[url: 'https://github.com/Csalcedo04/NoteApp-React.git']],
extensions: [[$class: 'UserIdentity', name: 'DSL User', email: '[email protected]']]
])
}
// Define un trigger para ejecutar este pipeline cada 5 minutos
properties([
pipelineTriggers([[$class: 'SCMTrigger', scmpoll_spec: 'H/5 * * * *']])
])
stage('Setup Node.js') {
echo "Starting Node.js Setup"
nodejs('nodejs') {
// Commands to execute in the Node.js environment
sh 'npm install'
}
echo "Node.js Setup Complete"
}
// Construye y publica la imagen en DockerHub
stage('Docker Build and Publish') {
script {
// Autenticar en Docker Hub y construir/publicar la imagen
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
def image = docker.build("csalcedo04/note_app-docker:latest")
image.push("latest") // Publica la imagen en DockerHub
}
}
}
}