diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 000000000..68aba6229
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,31 @@
+pipeline {
+ agent any
+
+ stages {
+
+ stage('Checkout Code') {
+ steps {
+ git branch: 'master', url: 'https://github.com/harshrajurkar/node-hello.git'
+ }
+ }
+
+ stage('Upload index.html to S3') {
+ steps {
+ withAWS(region: 'ap-south-1', credentials: 'aws-creds') {
+ s3Upload bucket: 'my-frontend-site-node',
+ file: 'index.html',
+ path: "index.html"
+ }
+ }
+ }
+ }
+
+ post {
+ success {
+ echo "index.html uploaded to S3 successfully!"
+ }
+ failure {
+ echo "Upload failed!"
+ }
+ }
+}
\ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 000000000..191222ce9
--- /dev/null
+++ b/index.html
@@ -0,0 +1,35 @@
+
+
+
+ My Simple Node Page
+
+
+
+
+
sucessfull deployemnt!
+
This webpage is served from a separate index.html file for s3...1..2..3..4....5
+
+
+
diff --git a/index.js b/index.js
index 54e5fef1f..cf047ec52 100644
--- a/index.js
+++ b/index.js
@@ -1,12 +1,23 @@
const http = require('http');
+const fs = require('fs');
+const path = require('path');
+
const port = process.env.PORT || 3000;
const server = http.createServer((req, res) => {
- res.statusCode = 200;
- const msg = 'Hello Node!\n'
- res.end(msg);
+ const filePath = path.join(__dirname, 'index.html');
+
+ fs.readFile(filePath, (err, content) => {
+ if (err) {
+ res.writeHead(500);
+ res.end('Error loading file');
+ } else {
+ res.writeHead(200, { 'Content-Type': 'text/html' });
+ res.end(content);
+ }
+ });
});
server.listen(port, () => {
- console.log(`Server running on http://localhost:${port}/`);
+ console.log(`Server running at http://localhost:${port}`);
});
diff --git a/package-lock.json b/package-lock.json
index 61b5dcb84..3b7b577d5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,13 @@
{
- "name": "papa-node-hello-000",
+ "name": "node-hello",
"version": "1.0.0",
- "lockfileVersion": 1
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "node-hello",
+ "version": "1.0.0",
+ "license": "ISC"
+ }
+ }
}