diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..2e128339 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,68 @@ +node{ + echo "Jenkins job name is : ${env.JOB_NAME}" + echo "build number is : ${env.BUILD_NUMBER}" + echo "node name is :${env.NODE_NAME}" + def mavenHome = tool name : "maven-3.9.9" + try{ + stage('git-checkot') + { + notifyBuild('STARTED') + git branch: 'feature-1', credentialsId: '6e1718d8-aa75-4745-b8cd-afa034bab3d1', + url: 'https://github.com/Idea-Better-5g/demo-java.git' + } + stage('complie'){ + sh "${mavenHome}/bin/mvn compile" + } + stage('build'){ + sh "${mavenHome}/bin/mvn clean package" + } + stage('SQ Report') + { + sh "${mavenHome}/bin/mvn sonar:sonar" + } + stage('Deploy into Nexus') + { + sh "${mavenHome}/bin/mvn clean deploy" + } + stage('deploy into tomcat'){ + sshagent(['247df6d4-99a1-46ce-9a95-47649bb3f49a']) { + + sh "scp -o StrictHostKeyChecking=no target/demo.war ec2-user@13.201.4.156:/opt/apache-tomcat-9.0.102/webapps" + } + } + }//try close + catch(e) { + currentBuild.result="FAILED" + throw e + }//catch close + finally{ + notifyBuild(currentBuild.result) + }//finally close +}//node close +def notifyBuild(String buildStatus = 'STARTED') { + // build status of null means successful + buildStatus = buildStatus ?: 'SUCCESS' + + // Default values + def colorName = 'RED' + def colorCode = '#FF0000' + def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" + def summary = "${subject} (${env.BUILD_URL})" + + // Override default values based on build status + if (buildStatus == 'STARTED') { + color = 'YELLOW' + colorCode = '#FFFF00' + } else if (buildStatus == 'SUCCESS') { + color = 'GREEN' + colorCode = '#00FF00' + } else { + color = 'RED' + colorCode = '#FF0000' + } + def channels = ["#black-tiger", "development", "#dreams-feature","#loginfeatures"] + // Send Slack message to each channel + for (channel in channels) { + slackSend(color: colorCode, message: summary, channel: channel) + } +} diff --git a/JenkinsfileModel b/JenkinsfileModel new file mode 100644 index 00000000..c8118f8a --- /dev/null +++ b/JenkinsfileModel @@ -0,0 +1,58 @@ +pipeline { + agent any + tools { + maven 'maven-3.9.9' + } + triggers { + pollSCM '0 0 1 * *' + } + + stages { + stage('Checkout Code') { + steps { + git branch: 'feature-1', credentialsId: '6e1718d8-aa75-4745-b8cd-afa034bab3d1', url: 'https://github.com/Idea-Better-5g/demo-java.git' + } + } + + stage('Compile') { + steps { + sh 'mvn compile' + } + } + + stage('Build') { + steps { + sh 'mvn clean package' + } + } + + stage('Sonar Report') { + steps { + sh 'mvn clean sonar:sonar' + } + } + + stage('Deploy Artifact') { + steps { + sh 'mvn clean deploy' + } + } + + stage('Deploy to Tomcat') { + steps { + sshagent(['247df6d4-99a1-46ce-9a95-47649bb3f49a']) { + sh "scp -o StrictHostKeyChecking=no target/demo.war ec2-user@3.108.64.244:/opt/apache-tomcat-9.0.102/webapps/" + } + } + } + } // stages close + + post { + success { + echo 'Pipeline executed successfully!' + } + failure { + echo 'Pipeline failed!' + } + } +} // pipeline close diff --git a/pom.xml b/pom.xml index 40a04099..5490223c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,8 @@ war 1.0-SNAPSHOT Demo Maven Webapp - https://github.com/tongueroo/demo-java + + demo src @@ -21,10 +22,42 @@ maven-war-plugin - 3.0.0 + 3.4.0 + + + 1.8 + 5.3.34 + 4.11 + 1.2.17 + http://13.201.30.42:9000/ + admin + 12345 + UTF-8 + UTF-8 + + + + + + + nexus + KK FUNDA Releases Nexus Repository + http://13.233.254.6:8081/repository/MRF-Release/ + + + + nexus + KK FUNDA Snapshot Nexus Repository + http://13.233.254.6:8081/repository/MRF-snapshot/ + + + + + + junit diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 8d86027e..5daf94e5 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,5 +1,81 @@ - + + + + + + Home Page + + -

Hello World: src/main/webapp/index.jsp

+
+

Welcome to My Dream World

+
+ +
+

About Our Website

+

Tts my world my Choice i can ruled

+
+