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
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM tomcat:7.0
MAINTAINER KISHORE@test.com
RUN apt-get update
RUN apt-get install -y vim
ADD target/ekart.war /usr/local/tomcat/webapps
ENTRYPOINT /usr/local/tomcat/bin/startup.sh && bash
50 changes: 50 additions & 0 deletions Jenkinsfile_parameter
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
pipeline {
agent label {'ubuntu-agent2'}
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'master', description: 'Branch to build')
credentials(name: 'DOCKERHUB_CREDENTIALS', description: 'Credentials for Docker Hub')
}

stages {
stage('Clone Repo') {
steps {
echo "Cloning repository ${params.BRANCH_NAME}"
git branch: params.BRANCH_NAME, changelog: false, credentialsId: 'sivanunna9', poll: false, url: 'git@github.com:testingdevops123/ekart.git'
}
}
stage('Build') {
steps {
echo "Building branch ${params.BRANCH_NAME}"
script {
def mvnHome = tool name: 'M3', type: 'maven'
sh "${mvnHome}/bin/mvn clean install"
}
}
}
stage('docker-build') {
steps {
echo "Building Docker image for build number ${env.BUILD_NUMBER}"
sh "docker build -t ekart:${env.BUILD_NUMBER} ."
}
}
stage('docker-push') {
steps {
echo "Pushing Docker image for build number ${BUILD_NUMBER} to Docker Hub"
withCredentials([usernamePassword(credentialsId: 'DOCKERHUB_CREDENTIALS', usernameVariable: 'DOCKERHUB_USER', passwordVariable: 'DOCKERHUB_PASS')]) {
sh '''
echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_USER --password-stdin
docker tag ekart:${BUILD_NUMBER} $DOCKERHUB_USER/ekart:${BUILD_NUMBER}
docker push $DOCKERHUB_USER/ekart:${BUILD_NUMBER}
'''
}
}
}

stage('docker-run') {
steps {
echo "Running Docker container for build number ${BUILD_NUMBER}"
// docker run --rm -d -p 8080:8080 ekart:${BUILD_NUMBER}
}
}
}
}
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@

<build>
<finalName>ekart</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>