-
Notifications
You must be signed in to change notification settings - Fork 880
Expand file tree
/
Copy pathJenkinsfile
More file actions
46 lines (40 loc) · 1.29 KB
/
Jenkinsfile
File metadata and controls
46 lines (40 loc) · 1.29 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
pipeline {
agent any
environment {
DOCKER_IMAGE = 'akshu20791/apachewebsite:latest'
// KUBECONFIG = credentials('kubeconfig')
}
stages {
stage('Clone Git repository') {
steps {
git 'https://github.com/akshu20791/apachewebsite/'
}
}
stage('run ansibleplaybook'){
steps{
ansiblePlaybook credentialsId: 'ansible-ssh', installation: 'ansible2', inventory: 'inventory.ini', playbook: 'installapche.yml', vaultTmpPath: ''
}
}
stage('Docker Build & Push') {
steps {
script {
withDockerRegistry([credentialsId: 'docker']) {
sh '''
echo "Building Docker image..."
docker build --no-cache -t $DOCKER_IMAGE -f Dockerfile .
echo "Pushing Docker image to Docker Hub..."
docker push $DOCKER_IMAGE
'''
}
}
}
}
stage('Deploy to Kubernetes') {
steps {
script{
kubernetesDeploy (configs: 'deployment.yml' ,kubeconfigId: 'k8sconfig')
}
}
}
}
}