-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile.dev
More file actions
58 lines (50 loc) · 1.61 KB
/
Copy pathJenkinsfile.dev
File metadata and controls
58 lines (50 loc) · 1.61 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
47
48
49
50
51
52
53
54
55
56
57
58
pipeline {
agent any
environment {
// Define Docker image tag and credentials ID
DOCKER_IMAGE = 'neupinion/neupinion'
DOCKER_LATEST_IMAGE = 'neupinion/neupinion:dev-latest'
DOCKER_CREDS = 'docker_hub'
}
stages {
stage('Prepare Environment') {
steps {
// Make the Gradle wrapper script executable
sh 'chmod +x gradlew'
}
}
stage('Build with Gradle') {
steps {
// Clean and build the project using Gradle wrapper
sh './gradlew clean build'
}
}
stage('Build Docker Image') {
steps {
// Build the Docker image
sh "docker build -t ${DOCKER_LATEST_IMAGE} ."
}
}
stage('Push to Docker Hub') {
steps {
// Log in to Docker Hub with --password-stdin
withCredentials([usernamePassword(credentialsId: DOCKER_CREDS, usernameVariable: 'DOCKERHUB_USERNAME', passwordVariable: 'DOCKERHUB_PASSWORD')]) {
sh "echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USERNAME} --password-stdin"
}
// Push the image to Docker Hub
sh "docker push --all-tags ${DOCKER_IMAGE}"
}
}
stage('Cleaning up') {
steps {
sh "echo Y | docker image prune -a"
}
}
}
post {
always {
// Post actions like cleaning up, notifications, etc.
echo 'Build process completed.'
}
}
}