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

Rnd #1

Open
wants to merge 25 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
67 changes: 67 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
def dockerImage

pipeline {
agent {
label 'RND-SERVER-03'
}
stages {
stage('Checkout') {
steps {
// Checkout the code from your Git repository
checkout scm
}
}
stage('Stop and Remove Docker Container') {
steps {
script {
// Define the Docker container name
def containerName = 'my-node-app'

// Check if the container is running
def isRunning = sh(script: "docker inspect -f '{{.State.Running}}' ${containerName}", returnStatus: true) == 0

if (isRunning) {
// Stop the existing container if it's running
sh "docker stop ${containerName}"

// Remove the existing container
sh "docker rm ${containerName}"

echo "Stopped and removed existing container: ${containerName}"
} else {
echo "Container ${containerName} is not running, no need to stop or remove."
}
}
}
}
stage('Build Docker Image') {
steps {
script {
// Define the Docker image name
dockerImage = 'my-node-app'
// Build the Docker image using the Dockerfile from the project directory
sh "docker build -t ${dockerImage} -f Dockerfile ."
// Replace "/path/to/your/Dockerfile" with the actual path to your Dockerfile
}
}
}
stage('Run Docker Container') {
steps {
script {
// Define the Docker container name
def containerName = 'my-node-app'
// Run the Docker container
sh "docker run --name ${containerName} -p 8080:8080 -d ${dockerImage}"
}
}
}
}
post {
success {
echo "Deployment successful!"
}
failure {
echo "Deployment failed!"
}
}
}
1 change: 1 addition & 0 deletions newfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It is a new file.
4 changes: 2 additions & 2 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</nav>
<div class="jumbotron">
<div class="container">
<h1>Want to Learn About Sharks?</h1>
<p>Are you ready to learn about sharks?</p>
<h1>Are you want to Learn About Sharks?</h1>
<p>Ready to learn about sharks?</p>
<br>
<p><a class="btn btn-primary btn-lg" href="/sharks" role="button">Get Shark Info</a>
</p>
Expand Down