-
Notifications
You must be signed in to change notification settings - Fork 60
/
Jenkinsfile
59 lines (57 loc) · 1.59 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pipeline {
agent any
environment {
IMAGE_NAME = 'sanjeevkt720/jenkins-flask-app'
IMAGE_TAG = "${IMAGE_NAME}:${env.BUILD_NUMBER}"
KUBECONFIG = credentials('kubeconfig-credentials-id')
}
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/kodekloudhub/jenkins-project.git', branch: 'main'
sh "ls -ltr"
}
}
stage('Setup') {
steps {
sh "pip install -r requirements.txt"
}
}
stage('Test') {
steps {
sh "pytest"
sh "whoami"
}
}
stage('Login to docker hub') {
steps {
withCredentials([string(credentialsId: 'dockerhubpwd', variable: 'dockerhubpwd')]) {
sh 'echo ${dockerhubpwd} | docker login -u sanjeevkt720 --password-stdin'}
echo 'Login successfully'
}
}
stage('Build Docker Image')
{
steps
{
sh 'docker build -t ${IMAGE_TAG} .'
echo "Docker image build successfully"
sh "docker images"
}
}
stage('Push Docker Image')
{
steps
{
sh 'docker push ${IMAGE_TAG}'
echo "Docker image push successfully"
}
}
stage('Deploy to EKS Cluster') {
steps {
sh "kubectl apply -f deployment.yaml"
echo "Deployed to EKS Cluster"
}
}
}
}