Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create scripted-jenkins #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
27 changes: 27 additions & 0 deletions declatariveway-script
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
2 changes: 2 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM tomcat:8.0.20-jre8
COPY target/SemesterProject.war /usr/local/tomcat/webapps/SemesterProject.war
26 changes: 26 additions & 0 deletions jenkins_docker-integration
Original file line number Diff line number Diff line change
@@ -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 [email protected] docker rm -f javawebappcontainer || true"
sh "ssh -o StrictHostkeyChecking=no [email protected] docker run -d -p 8080:8080 --name javawebappcontainer sudipto243/java-web-app:${buildNumber}"
}
}
}

17 changes: 17 additions & 0 deletions jenkinspipeline tomcat deployment
Original file line number Diff line number Diff line change
@@ -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 [email protected]:/opt/apache-tomcat-9.0.73/webapps"
}
}

}//closing node
10 changes: 10 additions & 0 deletions scripted-jenkins
Original file line number Diff line number Diff line change
@@ -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