Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
def getDockerTag(){
def tag = sh script: 'git rev-parse --short HEAD', returnStdout: true
return tag
}

pipeline{
agent any
environment{
Docker_tag = getDockerTag()
}
stages{
stage("Sonar scan"){
agent {
Expand Down Expand Up @@ -38,11 +46,52 @@ pipeline{
}
}

stage('docker login and build'){
steps{
script{
sh """
docker login -u admin -p admin 34.125.26.221:8083
cp -r ../ci-pull-request@2/target .
docker build . -t 34.125.26.221:8083/sample-web-app:$Docker_tag
docker push 34.125.26.221:8083/sample-web-app:$Docker_tag
"""

}
}
}

stage('prepare deplyment file'){
steps{
script{
sh '''
final_tag=$(echo $Docker_tag | tr -d ' ')
sed -i "s|TAG|$final_tag|" deployment.yaml
cat deployment.yaml
'''
}
}
}
stage('connect k8s cluster'){
steps{
script{
configFileProvider(
[configFile(fileId: 'kube-config-file', variable: 'KUBECONFIG')]) {
sh """
kubectl get po
kubectl apply -f deployment.yaml
"""
}
}
}
}


}

post {
always{
cleanWs()
sh 'kubectl delete -f deployment.yaml'
}
}
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ and build the instruction .
# Deploy instruction

Deploy ```target/WebApp.war``` on Tomcat properly for better experience.

2 changes: 1 addition & 1 deletion deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
spec:
containers:
- name: devops-training
image: deekshithsn/webapp:TAG
image: 34.125.26.221/sample-web-app:TAG
command: ["/bin/sh"]
args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
ports:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>lu.amazon.aws.demo</groupId>
<artifactId>WebApp</artifactId>
<packaging>war</packaging>
<version>2.0</version>
<version>2.0-SNAPSHOT</version>
<name>WebApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
Expand Down
3 changes: 0 additions & 3 deletions test

This file was deleted.