-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
41 lines (35 loc) · 1.27 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
37
38
39
40
41
pipeline {
agent { label "aws" }
stages {
stage('Git: Code Checkout') {
steps {
echo "Cloning the repository..."
git url: "https://github.com/amaan-igs/webdocs.git", branch: "main"
}
}
stage('Docker - Build') {
steps {
echo "Building project with Docker..."
sh "docker build -t webdocs:latest ."
}
}
stage('Docker Hub - Push') {
steps {
echo "Pushing to Dockerhub..."
withCredentials([usernamePassword(credentialsId:"HubDocker",
passwordVariable:"HubDockerPass", usernameVariable:"HubDockerUser")]){
sh "docker login -u ${env.HubDockerUser} -p ${env.HubDockerPass}"
sh "docker image tag webdocs:latest ${env.HubDockerUser}/webdocs:latest"
sh "docker push ${env.HubDockerUser}/webdocs:latest"
}
}
}
stage('Docker-Compose') {
steps {
echo "Launching services with docker-compose..."
sh "docker-compose up -d"
}
}
}
}
// Declarative Pipeline for building testing and deploying to dockerhub.