forked from ChaitaliP2001/Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
35 lines (32 loc) · 1.34 KB
/
Jenkinsfile
File metadata and controls
35 lines (32 loc) · 1.34 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
pipeline {
agent any
stages {
stage('Clean existing Built Containers'){
steps {
sh 'docker rmi -f hub.enlight.dev/360-containers/sample1:$BRANCH_NAME || true'
}
}
stage('Build container Image'){
steps{
echo '$BRANCH_NAME'
sh 'docker build -t hub.enlight.dev/360-containers/sample1:$BRANCH_NAME .'
}
}
stage('Push Image'){
steps{
withDockerRegistry(credentialsId: 'enlight360-dev-hub', url: 'https://hub.enlight.dev')
{
sh 'docker push hub.enlight.dev/360-containers/sample1:$BRANCH_NAME'
}
}
}
stage('Deploying App to Kubernetes') {
steps {
script {
sshPublisher(publishers: [sshPublisherDesc(configName: 'ansible', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''ansible-playbook -i /etc/ansible/hosts /opt/k8-lab/ans-vault.yaml;
ansible-playbook -i /etc/ansible/hosts /opt/k8-lab/cicd-deploy1.yml''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '/opt/k8-lab/', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true)])
}
}
}
}
}