diff --git a/declatariveway-script b/declatariveway-script new file mode 100644 index 0000000..9ea8bb6 --- /dev/null +++ b/declatariveway-script @@ -0,0 +1,27 @@ +pipeline { + triggers { + pollSCM '* * * * *' +} + options { + buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '2', numToKeepStr: '2') +} + agent any + + tools { + // Install the Maven version configured as "M3" and add it to the path. + maven "mvn3.9.1" + } + + stages { + stage('checkoutcode') { + steps { + git 'https://github.com/sudip243/Todolist.git' + } + } + stage('build') { + steps { + sh "mvn clean package" + } + } + } +} diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..2400dac --- /dev/null +++ b/dockerfile @@ -0,0 +1,2 @@ +FROM tomcat:8.0.20-jre8 +COPY target/SemesterProject.war /usr/local/tomcat/webapps/SemesterProject.war diff --git a/jenkins_docker-integration b/jenkins_docker-integration new file mode 100644 index 0000000..eeb5445 --- /dev/null +++ b/jenkins_docker-integration @@ -0,0 +1,26 @@ +node{ + def buildNumber = BUILD_NUMBER + stage("Git Clone"){ + git 'https://github.com/sudip243/Todolist.git' + } + stage("Maven Clean Package"){ + def mavenHome= tool name: "mvn3.9.2",type: "maven" + sh "${mavenHome}/bin/mvn clean package" + } + stage("Build Docker Image"){ + sh "docker build -t sudipto243/java-web-app:${buildNumber} ." + } + stage("Docker login and Push"){ + withCredentials([string(credentialsId: 'dockerhubpass', variable: 'dockerhubpass')]) { + sh "docker login -u sudipto243 -p ${dockerhubpass}" +} + sh "docker push sudipto243/java-web-app:${buildNumber}" + } + stage("Deploy application as docker container in docker deployment server"){ + sshagent(['docker_dev_server_ssh']) { + sh "ssh -o StrictHostkeyChecking=no ubuntu@172.31.0.85 docker rm -f javawebappcontainer || true" + sh "ssh -o StrictHostkeyChecking=no ubuntu@172.31.0.85 docker run -d -p 8080:8080 --name javawebappcontainer sudipto243/java-web-app:${buildNumber}" +} + } +} + diff --git a/jenkinspipeline tomcat deployment b/jenkinspipeline tomcat deployment new file mode 100644 index 0000000..3c05130 --- /dev/null +++ b/jenkinspipeline tomcat deployment @@ -0,0 +1,17 @@ +node { + //checkout stage + stage ('checkout'){ + git 'https://github.com/sudip243/Todolist.git' + } + //build stage + stage ('build'){ + sh "mvn clean package" + } + //deploy app into tomacat server + stage ('deploy into tomcat'){ + sshagent(['9c752a68-2ab7-4ce5-98d3-651ae91cfb14']) { + sh "scp -o StrictHostKeyChecking=no target/SemesterProject.war ubuntu@172.31.94.104:/opt/apache-tomcat-9.0.73/webapps" +} + } + +}//closing node diff --git a/scripted-jenkins b/scripted-jenkins new file mode 100644 index 0000000..f03f994 --- /dev/null +++ b/scripted-jenkins @@ -0,0 +1,10 @@ +node { + def mavenHome = tool name : "mvn3.9.1" + //checkout stage + stage ('checkout Code') { + git 'https://github.com/sudip243/Todolist.git' + } + stage ('Build') { + sh "$mavenHome/bin/mvn clean package" + } +}//closing node