diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..f1f1d4e5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,88 @@ +pipeline { + agent { + label 'maven' // Use your Maven server as the agent + } + + environment { + GITHUB_TOKEN = credentials('github-token-id') + } + + stages { + stage('Git Checkout') { + steps { + // This will checkout the code from the correct branch + git url: 'https://github.com/vickeyys/jenkins-java-project-1.git', credentialsId: 'github-token-id' + } + } + + stage('Compile') { + steps { + script { + if (env.BRANCH_NAME == 'prod') { + echo "Compiling for Production" + // Compile with prod profile + sh 'mvn clean compile -P prod' + } else if (env.BRANCH_NAME == 'stag') { + echo "Compiling for Staging" + // Compile with stag profile + sh 'mvn clean compile -P stag' + } else { + echo "No valid environment for branch: ${env.BRANCH_NAME}" + } + } + } + } + + stage('Test') { + steps { + script { + if (env.BRANCH_NAME == 'prod') { + echo "Running tests for Production" + // Test with prod profile + sh 'mvn test -P prod' + } else if (env.BRANCH_NAME == 'stag') { + echo "Running tests for Staging" + // Test with stag profile + sh 'mvn test -P stag' + } else { + echo "No valid environment for branch: ${env.BRANCH_NAME}" + } + } + } + } + + stage('Build') { + steps { + script { + if (env.BRANCH_NAME == 'prod') { + echo "Building for Production" + // Build with prod profile + sh 'mvn package -P prod' + } else if (env.BRANCH_NAME == 'stag') { + echo "Building for Staging" + // Build with stag profile + sh 'mvn package -P stag' + } else { + echo "No valid environment for branch: ${env.BRANCH_NAME}" + } + } + } + } + + stage('Deploy') { + steps { + script { + if (env.BRANCH_NAME == 'prod') { + echo "Deploying to Production" + // Add your production deployment steps here + } else if (env.BRANCH_NAME == 'stag') { + echo "Deploying to Staging" + // Add your staging deployment steps here + } else { + echo "Branch ${env.BRANCH_NAME} is not recognized" + } + } + } + } + } +} diff --git a/pom.xml b/pom.xml index 01e0d5a2..d553e4aa 100644 --- a/pom.xml +++ b/pom.xml @@ -1,51 +1,76 @@ - 4.0.0 - in.RAHAM - NETFLIX - war - 1.2.2 - Java Home myweb - http://maven.apache.org - - - kammana - - - - com.oracle.bedrock - bedrock-runtime-maven - 5.1.2 - - - - junit - junit - 3.8.1 - test - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + in.RAHAM + NETFLIX + war + 1.2.2 + Java Home myweb + http://maven.apache.org + + + kammana + + + + + com.oracle.bedrock + bedrock-runtime-maven + 5.1.2 + + + + junit + junit + 3.8.1 + test + + + + + + nexusRepo + http://13.233.230.166:8081/repository/maven-snapshots/ + + + + nexusRepo + http://13.233.230.166:8081/repository/maven-releases/ + + + + + + maven1 + Maven.org + http://repo1.maven.org/maven2 + + - - - - - nexusRepo - http://13.233.230.166:8081/repository/maven-snapshots/ - - - - nexusRepo - http://13.233.230.166:8081/repository/maven-releases/ - - - - - - maven1 - Maven.org - http://repo1.maven.org/maven2 - - + + + + + stag + + staging + ${project.build.directory}/stag + + + NETFLIX-stag + + - + + + prod + + production + ${project.build.directory}/prod + + + NETFLIX-prod + + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index d7c1c21a..409b5a32 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -23,7 +23,7 @@ - +