Skip to content
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
14 changes: 7 additions & 7 deletions GitOps/Jenkinsfile → Argo-cd/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Library('Shared') _
pipeline {
agent {label 'Node'}
agent any

parameters {
string(name: 'FRONTEND_DOCKER_TAG', defaultValue: '', description: 'Frontend Docker tag of the image built by the CI job')
Expand All @@ -19,7 +19,7 @@ pipeline {
stage('Git: Code Checkout') {
steps {
script{
code_checkout("https://github.com/DevMadhup/Wanderlust-Mega-Project.git","main")
code_clone("https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git","master")
}
}
}
Expand All @@ -39,13 +39,13 @@ pipeline {
script{
dir('kubernetes'){
sh """
sed -i -e s/wanderlust-backend-beta.*/wanderlust-backend-beta:${params.BACKEND_DOCKER_TAG}/g backend.yaml
sed -i -e s/wanderlust-backend.*/wanderlust-backend:${params.BACKEND_DOCKER_TAG}/g backend.yaml
"""
}

dir('kubernetes'){
sh """
sed -i -e s/wanderlust-frontend-beta.*/wanderlust-frontend-beta:${params.FRONTEND_DOCKER_TAG}/g frontend.yaml
sed -i -e s/wanderlust-frontend.*/wanderlust-frontend:${params.FRONTEND_DOCKER_TAG}/g frontend.yaml
"""
}

Expand All @@ -56,7 +56,7 @@ pipeline {
stage("Git: Code update and push to GitHub"){
steps{
script{
withCredentials([gitUsernamePassword(credentialsId: 'Github-cred', gitToolName: 'Default')]) {
withCredentials([gitUsernamePassword(credentialsId: 'GitHub', gitToolName: 'Default')]) {
sh '''
echo "Checking repository status: "
git status
Expand All @@ -68,7 +68,7 @@ pipeline {
git commit -m "Updated environment variables"

echo "Pushing changes to github: "
git push https://github.com/DevMadhup/Wanderlust-Mega-Project.git main
git push https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git master
'''
}
}
Expand Down Expand Up @@ -101,4 +101,4 @@ pipeline {
}
}
}
}
}
10 changes: 5 additions & 5 deletions Automations/updatebackendnew.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# Set the Instance ID and path to the .env file
INSTANCE_ID="i-0ee177c8f3cdd7103"
INSTANCE_ID="i-0175d7325693884e7"

# Retrieve the public IP address of the specified EC2 instance
ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)
ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --region us-west-1 --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)

# Initializing variables
file_to_find="../backend/.env.docker"
Expand All @@ -18,7 +18,7 @@ NC='\033[0m'

echo -e " ${GREEN}System Public Ipv4 address ${NC} : ${ipv4_address}"

if [[ "${alreadyUpdate}" == "FRONTEND_URL=\"http://${ipv4_address}:5173\"" ]]
if [[ "${alreadyUpdate}" == "FRONTEND_URL=\"http://${ipv4_address}:31000\"" ]]
then
echo -e "${YELLOW}${file_to_find} file is already updated to the current host's Ipv4 ${NC}"
else
Expand All @@ -27,9 +27,9 @@ else
echo -e "${GREEN}${file_to_find}${NC} found.."
echo -e "${YELLOW}Configuring env variables in ${NC} ${file_to_find}"
sleep 7s;
sed -i -e "s|FRONTEND_URL.*|FRONTEND_URL=\"http://${ipv4_address}:5173\"|g" ${file_to_find}
sed -i -e "s|FRONTEND_URL.*|FRONTEND_URL=\"http://${ipv4_address}:31000\"|g" ${file_to_find}
echo -e "${GREEN}env variables configured..${NC}"
else
echo -e "${RED}ERROR : File not found..${NC}"
fi
fi
fi
6 changes: 3 additions & 3 deletions Automations/updatefrontendnew.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# Set the Instance ID and path to the .env file
INSTANCE_ID="i-0ee177c8f3cdd7103"
INSTANCE_ID="i-0bcf7ebe5af5670f3"

# Retrieve the public IP address of the specified EC2 instance
ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)
ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --region us-west-1 --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)

# Initializing variables
file_to_find="../frontend/.env.docker"
Expand All @@ -30,4 +30,4 @@ else
else
echo -e "${RED}ERROR : File not found..${NC}"
fi
fi
fi
85 changes: 38 additions & 47 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
@Library('Shared') _
@Library('shared') _
pipeline {
agent {label 'Node'}
agent any

environment{
SONAR_HOME = tool "Sonar"
}

parameters {
string(name: 'FRONTEND_DOCKER_TAG', defaultValue: '', description: 'Setting docker image for latest push')
string(name: 'BACKEND_DOCKER_TAG', defaultValue: '', description: 'Setting docker image for latest push')
SONAR_HOME = tool "Sonarqube"
}

stages {
Expand All @@ -18,49 +13,47 @@ pipeline {
script{
cleanWs()
}
sh "docker system prune -a -f"
}
}

stage('Git: Code Checkout') {
steps {
script{
code_checkout("https://github.com/DevMadhup/Wanderlust-Mega-Project.git","main")
code_clone("https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git","master")
}
Comment on lines 20 to 24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find the Jenkinsfile
find . -name "Jenkinsfile" -o -name "Jenkinsfile*" | head -20

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 112


🏁 Script executed:

#!/bin/bash
# Read the main Jenkinsfile
cat -n ./Jenkinsfile

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 4039


🏁 Script executed:

#!/bin/bash
# Search for code_clone function definition
rg "def code_clone" --type groovy -A 10

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 225


🏁 Script executed:

#!/bin/bash
# Search for code_clone in all files
rg "code_clone" --type all -B 2 -A 5

# Also look for shared library structure
echo "---"
find . -name "vars" -o -name "src" -type d | grep -E "(vars|src)"

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 95


🏁 Script executed:

#!/bin/bash
# Search without type filter
rg "code_clone" -A 5 -B 2

# Check if there are any pipeline-related files
echo "---"
git ls-files | grep -i -E "(shared|library|vars|pipeline)" | head -20

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 816


🏁 Script executed:

#!/bin/bash
# Check for trigger definitions and environment variables
cat -n ./Jenkinsfile | grep -E "(trigger|GIT_BRANCH|BRANCH_NAME|properties)"

# Check Argo-cd Jenkinsfile for comparison
echo "--- Argo-cd/Jenkinsfile ---"
cat ./Argo-cd/Jenkinsfile | head -30

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 1012


🏁 Script executed:

#!/bin/bash
# Check for any README or documentation
find . -name "README*" -o -name "CONTRIBUTING*" -o -name "*jenkinsfile*" | grep -v node_modules | grep -v ".git"

# Check git branch configuration
echo "---"
git config --get-regexp branch || echo "No branch config found"

# Check if there are Jenkinsfiles in subdirectories (multi-branch indicator)
echo "---"
find . -name "Jenkinsfile" -type f

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 232


Hardcoded master branch checkout conflicts with repository's default main branch.

Line 23 hardcodes code_clone("...","master") while the repository's default branch is main (confirmed in git config). This causes PR builds and main branch builds to checkout the wrong commit, leading to incorrect scans, builds, and image pushes. Use checkout scm instead to dynamically track the triggering revision.

Recommended fix
-                    code_clone("https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git","master")
+                    checkout scm

Note: The same issue exists in Argo-cd/Jenkinsfile at line 23.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Jenkinsfile` around lines 20 - 24, The pipeline is hardcoding the branch in
code_clone("https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git","master")
which conflicts with the repo's default branch (main) and breaks PR/triggered
builds; replace this explicit call with a dynamic checkout that uses the
triggering revision (e.g., use the declarative/Scripted pipeline built-in
checkout scm) so the pipeline tracks the actual triggering commit/branch; update
the same change in the Argo-cd/Jenkinsfile as well and remove the hardcoded
"master" argument from any code_clone usages.

}
}

stage("Trivy: Filesystem scan"){
steps{
script{
trivy_scan()
}
}
}

stage("OWASP: Dependency check"){
steps{
script{
owasp_dependency()
}
}
}
stage("Trivy: Filesystem scan"){
steps{
script{
trivy_scan()
}
}
}
// stage("OWASP: Dependency check"){
// steps{
// script{
// owasp_dependency()
// }
// }
// }

stage("SonarQube: Code Analysis"){
steps{
script{
sonarqube_analysis("Sonar","wanderlust","wanderlust")
sonar_analysis("Sonar","wanderlust","wanderlust")
}
}
}

stage("SonarQube: Code Quality Gates"){
stage("SonarQube: Code Quality Gates"){
steps{
script{
sonarqube_code_quality()
code_quality()
}
}
}

stage('Exporting environment variables') {
parallel{
stage("Backend env setup"){
Expand All @@ -84,37 +77,35 @@ pipeline {
}
}
}

stage("Docker: Build Images"){
stage("Docker: Build Images"){
steps{
script{
dir('backend'){
docker_build("wanderlust-backend-beta","${params.BACKEND_DOCKER_TAG}","madhupdevops")
image_build("wanderlust-backend","$BUILD_NUMBER","dooms002")
}

dir('frontend'){
docker_build("wanderlust-frontend-beta","${params.FRONTEND_DOCKER_TAG}","madhupdevops")
}
image_build("wanderlust-frontend","$BUILD_NUMBER","dooms002")
}
}
}
}

stage("Docker: Push to DockerHub"){
steps{
script{
docker_push("wanderlust-backend-beta","${params.BACKEND_DOCKER_TAG}","madhupdevops")
docker_push("wanderlust-frontend-beta","${params.FRONTEND_DOCKER_TAG}","madhupdevops")
docker_push("wanderlust-backend","$BUILD_NUMBER","dooms002")
docker_push("wanderlust-frontend","$BUILD_NUMBER","dooms002")
}
}
}
}
post{
success{
archiveArtifacts artifacts: '*.xml', followSymlinks: false
build job: "Wanderlust-CD", parameters: [
string(name: 'FRONTEND_DOCKER_TAG', value: "${params.FRONTEND_DOCKER_TAG}"),
string(name: 'BACKEND_DOCKER_TAG', value: "${params.BACKEND_DOCKER_TAG}")
]
}
}
}
// post{
// success{
// archiveArtifacts artifacts: '*.xml', followSymlinks: false
// // build job: "Wanderlust-CD", parameters: [
// // string(name: 'FRONTEND_DOCKER_TAG', value: "$BUILD_NUMBER"),
// // string(name: 'BACKEND_DOCKER_TAG', value: "$BUILD_NUMBER")
// // ]
// }
// }
Comment on lines +102 to +110

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, find the Jenkinsfile in the repository
find . -name "Jenkinsfile" -type f | head -20

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 112


🏁 Script executed:

# Check the total lines in main Jenkinsfile and read around lines 102-110
wc -l ./Jenkinsfile
echo "---"
sed -n '95,115p' ./Jenkinsfile

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 716


🏁 Script executed:

# Check Argo-cd/Jenkinsfile around lines 5-8
wc -l ./Argo-cd/Jenkinsfile
echo "---"
sed -n '1,20p' ./Argo-cd/Jenkinsfile

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 672


🏁 Script executed:

# Search for references to FRONTEND_DOCKER_TAG and BACKEND_DOCKER_TAG in the codebase
rg "FRONTEND_DOCKER_TAG|BACKEND_DOCKER_TAG" -n

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 1074


🏁 Script executed:

# Search for references to "Wanderlust-CD" and any webhook/trigger configurations
rg "Wanderlust-CD|webhook|trigger|parameterized" -i -n

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 344


The CI→CD handoff is currently broken.

Lines 102-109 comment out the only mechanism that supplied FRONTEND_DOCKER_TAG and BACKEND_DOCKER_TAG to the Argo-cd/Jenkinsfile CD pipeline. The CI job pushes images with $BUILD_NUMBER tags (lines 97-99), but the CD pipeline will now receive empty parameters and deploy without knowing which image tags to use. Uncomment the trigger to Wanderlust-CD job or implement an alternative handoff mechanism.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Jenkinsfile` around lines 102 - 110, Uncomment or restore the CD handoff so
the Wanderlust-CD job receives the image tags: re-enable the post success block
that calls build job: "Wanderlust-CD" with parameters string(name:
'FRONTEND_DOCKER_TAG', value: "$BUILD_NUMBER") and string(name:
'BACKEND_DOCKER_TAG', value: "$BUILD_NUMBER") (or implement an equivalent
mechanism) so the CD pipeline gets the same BUILD_NUMBER tags the CI pushed;
ensure archiveArtifacts remains if needed and that the trigger executes only on
successful CI completion.

}
6 changes: 3 additions & 3 deletions backend/.env.docker
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
MONGODB_URI="mongodb://mongo-service/wanderlust"
MONGODB_URI="mongodb://mongo-service:27017/wanderlust"
REDIS_URL="redis://redis-service:6379"
PORT=8080
FRONTEND_URL="http://34.213.249.66:5173"
FRONTEND_URL="http://34.213.249.66:31000"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

This FRONTEND_URL edit is a no-op right now.

In the provided backend wiring, backend/config/utils.js:1-8 only exports PORT, MONGODB_URI, and REDIS_URL, so Line 4 is not consumed anywhere at runtime. If this was meant to change CORS or callback origins, that wiring is still missing.

🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 4-4: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 4-4: [UnorderedKey] The FRONTEND_URL key should go before the MONGODB_URI key

(UnorderedKey)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/.env.docker` at line 4, The FRONTEND_URL entry in backend/.env.docker
is currently unused because backend/config/utils.js only exports PORT,
MONGODB_URI, and REDIS_URL; either remove this unused FRONTEND_URL from the env
file or wire it into the backend by adding FRONTEND_URL to
backend/config/utils.js exports and then use that value where origins/CORS or
callback URLs are configured (e.g., in your CORS middleware or auth callback
configuration); update any relevant code that reads from
process.env.FRONTEND_URL so the value is actually consumed at runtime.

ACCESS_COOKIE_MAXAGE=120000
ACCESS_TOKEN_EXPIRES_IN='120s'
REFRESH_COOKIE_MAXAGE=120000
REFRESH_TOKEN_EXPIRES_IN='120s'
JWT_SECRET=70dd8b38486eee723ce2505f6db06f1ee503fde5eb06fc04687191a0ed665f3f98776902d2c89f6b993b1c579a87fedaf584c693a106f7cbf16e8b4e67e9d6df
NODE_ENV=Development
NODE_ENV=Development

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find and check if backend/.env.docker exists
find . -type f -name ".env.docker" | head -20

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 121


🏁 Script executed:

# List files in backend directory to understand structure
ls -la backend/ 2>/dev/null | head -20

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 1260


🏁 Script executed:

# Check if Dockerfile exists in backend directory
ls -la backend/Dockerfile* 2>/dev/null

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 143


🏁 Script executed:

# Read the backend/.env.docker file with line numbers
cat -n backend/.env.docker

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 573


🏁 Script executed:

# Read the backend/Dockerfile with line numbers to check line 25
cat -n backend/Dockerfile

Repository: DevMadhup/Wanderlust-Mega-Project

Length of output: 657


🌐 Web query:

NODE_ENV case sensitivity Node.js environment variable

💡 Result:

In Node.js, access to environment variables via process.env is case-sensitive on Unix-like systems (Linux, macOS) and case-insensitive on Windows. This behavior mirrors the underlying operating system's handling of environment variables. NODE_ENV specifically follows this pattern: process.env.NODE_ENV === process.env.node_env on Windows (both return the value if set), but on Unix, process.env.node_env is undefined if only NODE_ENV is set. This is intentional Node.js behavior, tested since v6 (commit 1d79af6), using Windows APIs like GetEnvironmentVariableW which perform case-insensitive lookups. Official Node.js process documentation confirms: "On Windows operating systems, environment variables are case-insensitive." with example: env.TEST = 1; console.log(env.test); // => 1 Note: In worker threads prior to recent fixes, behavior differed on Windows, but main thread access is consistent. .env files and dotenv parse keys case-sensitively before assigning to process.env. For cross-platform code, always use consistent casing (convention: uppercase like NODE_ENV) to avoid issues.

Citations:


🌐 Web query:

NODE_ENV development vs Development Node.js standard values

💡 Result:

In Node.js, there is no official standard or enforced set of values for the NODE_ENV environment variable. Node.js core does not define or use NODE_ENV specifically; it treats all environment variables as arbitrary strings via process.env. NODE_ENV is a community convention popularized by frameworks like Express.js and libraries in the npm ecosystem. Standard conventional values (all lowercase): - 'production': Optimizes libraries for performance (e.g., Express caching, less verbose errors). - 'development': Enables debugging features in many libraries (default assumption if unset in some contexts). - 'test': Commonly used for testing environments. 'development' (lowercase) vs 'Development' (title case): All authoritative sources and examples use lowercase 'development'. No sources recommend or show title case 'Development' as standard. Using title case would not trigger expected behaviors in libraries checking for exact string matches like === 'development' or === 'production', potentially causing apps to fall back to development mode or undefined behavior. Environment variable values are case-sensitive strings. Official Node.js docs confirm no special handling for NODE_ENV and note some libraries default to 'development' if unset. Node.js guides recommend always setting NODE_ENV=production (lowercase) everywhere for consistency, even in development/testing, to avoid antipatterns where behavior changes based on the value. Examples: - Official Node.js: NODE_ENV=production - Express convention: if (process.env.NODE_ENV === 'production') - package.json scripts: "start": "NODE_ENV=production node app.js" Best practice: Use lowercase strings matching library expectations. Avoid setting from within code; set externally (CLI, .env files, deployment configs).

Citations:


Use lowercase development for NODE_ENV.

Line 10 sets Development, but Node.js tools check NODE_ENV case-sensitively against standard values like development and production. On Linux systems (where Docker runs), this mismatch will cause libraries relying on equality checks like process.env.NODE_ENV === 'development' to fail, potentially triggering unexpected fallback behavior. Since backend/Dockerfile:25 copies this file into the runtime image, the container will boot with a non-standard environment value.

🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 10-10: [EndingBlankLine] No blank line at the end of the file

(EndingBlankLine)


[warning] 10-10: [UnorderedKey] The NODE_ENV key should go before the PORT key

(UnorderedKey)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/.env.docker` at line 10, The NODE_ENV value in backend/.env.docker is
set to "Development"; change it to the lowercase standard "development" (update
the NODE_ENV variable to NODE_ENV=development), ensure there are no stray quotes
or whitespace, and commit the change so the container runtime uses the correct
environment value.

2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ COPY .env.docker .env
EXPOSE 8080

# App
CMD ["npm", "start"]
CMD ["npm", "start"]
7 changes: 0 additions & 7 deletions database/Dockerfile

This file was deleted.

39 changes: 0 additions & 39 deletions docker-compose.yml

This file was deleted.

Loading