Skip to content
Open

Stag #37

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
88 changes: 88 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}
119 changes: 72 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,51 +1,76 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>in.RAHAM</groupId>
<artifactId>NETFLIX</artifactId>
<packaging>war</packaging>
<version>1.2.2</version>
<name>Java Home myweb</name>
<url>http://maven.apache.org</url>

<properties>
<docker.image.prefix>kammana</docker.image.prefix>
</properties>
<dependencies>
<dependency>
<groupId>com.oracle.bedrock</groupId>
<artifactId>bedrock-runtime-maven</artifactId>
<version>5.1.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>in.RAHAM</groupId>
<artifactId>NETFLIX</artifactId>
<packaging>war</packaging>
<version>1.2.2</version>
<name>Java Home myweb</name>
<url>http://maven.apache.org</url>

<properties>
<docker.image.prefix>kammana</docker.image.prefix>
</properties>

<dependencies>
<dependency>
<groupId>com.oracle.bedrock</groupId>
<artifactId>bedrock-runtime-maven</artifactId>
<version>5.1.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>nexusRepo</id>
<url>http://13.233.230.166:8081/repository/maven-snapshots/</url>
</snapshotRepository>

<repository>
<id>nexusRepo</id>
<url>http://13.233.230.166:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>

<pluginRepositories>
<pluginRepository>
<id>maven1</id>
<name>Maven.org</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>

</dependencies>

<distributionManagement>
<snapshotRepository>
<id>nexusRepo</id>
<url>http://13.233.230.166:8081/repository/maven-snapshots/</url>
</snapshotRepository>

<repository>
<id>nexusRepo</id>
<url>http://13.233.230.166:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>

<pluginRepositories>
<pluginRepository>
<id>maven1</id>
<name>Maven.org</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<!-- Maven Profiles -->
<profiles>
<!-- Staging Profile -->
<profile>
<id>stag</id>
<properties>
<environment>staging</environment>
<build.output.directory>${project.build.directory}/stag</build.output.directory>
</properties>
<build>
<finalName>NETFLIX-stag</finalName>
</build>
</profile>


<!-- Production Profile -->
<profile>
<id>prod</id>
<properties>
<environment>production</environment>
<build.output.directory>${project.build.directory}/prod</build.output.directory>
</properties>
<build>
<finalName>NETFLIX-prod</finalName>
</build>
</profile>
</profiles>
</project>
2 changes: 1 addition & 1 deletion src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<input type="password" required />
<label>Password</label>
</div>
<button type="submit">WELCOME TO NETFLIX V-6.0</button>
<button type="submit">WELCOME TO NETFLIX V-3.0</button>
<div class="form-help">
<div class="remember-me">
<input type="checkbox" id="remember-me" />
Expand Down