Skip to content

Conversation

@drtechie
Copy link
Member

@drtechie drtechie commented Jan 25, 2025

📋 Description

  • Update instructions for DB setup
  • Update the load script to make it run in Unix envs

✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

Summary by CodeRabbit

  • Documentation

    • Updated README.md with clearer heading for Database Schema Management Service Deployment
    • Added detailed setup instructions for database schema configuration
  • Chores

    • Modified shell script to improve structure and readability
    • Simplified array declarations and iteration logic in the load dummy data script
  • New Features

    • Introduced a comprehensive Jenkins pipeline automating build, packaging, and deployment for multiple projects and microservices across environments

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2025

Walkthrough

The pull request enhances the local setup documentation by refining the database schema management service deployment section with a clearer heading and added setup instructions. The shell script for loading dummy data is revised to improve portability and readability by switching from associative arrays to standard indexed arrays and adjusting the iteration logic accordingly. Additionally, a new Jenkins pipeline script is introduced to automate the build, packaging, and deployment processes for multiple UI and API projects, including environment setup, source checkout, build, artifact archiving, and remote deployment.

Changes

File Change Summary
amrit-local-setup/README.md - Updated section heading from "Schema Management Service Deployment" to "Database Schema Management Service Deployment"
- Added new "Setup instructions" subsection with detailed deployment steps
amrit-local-setup/loaddummydata.sh - Changed shebang from #!/bin/bash to #!/bin/sh
- Replaced associative arrays with standard indexed arrays
- Modified variable declarations for FILES and DATABASES
- Updated loop to iterate over array indices
Jenkinsfile - Added new Jenkins pipeline with multiple stages for building and packaging UI and API projects
- Configured environment variables and credentials per project
- Included stages for source checkout, dependency installation, build, artifact archiving
- Added deployment stages to undeploy existing WARs and deploy new WARs on remote WildFly server via SSH and SCP

Sequence Diagram(s)

sequenceDiagram
    participant Jenkins as Jenkins Pipeline
    participant Git as Git Repositories
    participant Build as Build Tools (npm, Maven)
    participant Archive as Artifact Storage
    participant Remote as Remote WildFly Server

    Jenkins->>Git: Checkout UI and API source code
    Jenkins->>Build: Install dependencies and build projects
    Build->>Archive: Archive WAR artifacts
    Jenkins->>Remote: Undeploy existing WARs via SSH
    Jenkins->>Remote: Deploy new WARs via SCP
Loading

Poem

🐇 Pipelines hum and scripts align,
Rabbit hops through code divine.
Arrays now simple, docs refined,
Builds and deploys all combined.
With every step, the magic grows,
In every line, the rabbit shows! 🛠️✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
amrit-local-setup/loaddummydata.sh (1)

Line range hint 1-8: Consider security and usability improvements for connection details.

  1. Database credentials are hardcoded. Consider:
    • Using environment variables
    • Adding a configuration file
    • Implementing password prompt
  2. The SQL_DIR placeholder needs clearer instructions for users.

Apply this diff to improve security and usability:

 #!/bin/sh

 # MySQL connection details
-HOST="127.0.0.1"
-PORT="3306"
-USER="root"
-PASSWORD="1234"
+HOST="${MYSQL_HOST:-127.0.0.1}"
+PORT="${MYSQL_PORT:-3306}"
+USER="${MYSQL_USER:-root}"
+PASSWORD="${MYSQL_PASSWORD:-}"  # Prompt if not set
+
+if [ -z "$PASSWORD" ]; then
+    echo -n "Enter MySQL password: "
+    read -s PASSWORD
+    echo
+fi

 # Path to the extracted SQL files
-SQL_DIR=<PATH to the extracted files directory>
+SQL_DIR="${SQL_DIR:-./sql_files}"  # Default to ./sql_files
+
+if [ ! -d "$SQL_DIR" ]; then
+    echo "Error: Directory $SQL_DIR does not exist."
+    echo "Please set SQL_DIR to the path of your extracted SQL files."
+    exit 1
+fi
🧹 Nitpick comments (2)
amrit-local-setup/loaddummydata.sh (1)

12-14: Consider a more robust file-to-database mapping approach.

While using parallel arrays works, it's prone to errors if the arrays get out of sync during maintenance. Consider using a configuration file that explicitly maps files to databases.

Example configuration file approach:

-# Files and their respective databases
-FILES=("AmritMasterData.sql" "m_beneficiaryregidmapping_dump_1097.sql" "m_beneficiaryregidmapping_dump.sql")
-DATABASES=("db_iemr" "db_1097_identity" "db_identity")
+# Read mappings from config file
+CONFIG_FILE="${CONFIG_FILE:-./db_mappings.conf}"
+
+if [ ! -f "$CONFIG_FILE" ]; then
+    cat > "$CONFIG_FILE" << EOF
+AmritMasterData.sql:db_iemr
+m_beneficiaryregidmapping_dump_1097.sql:db_1097_identity
+m_beneficiaryregidmapping_dump.sql:db_identity
+EOF
+    echo "Created default $CONFIG_FILE"
+fi
amrit-local-setup/README.md (1)

Line range hint 40-58: Enhance setup instructions with additional details.

While the instructions are clear, they could be more comprehensive:

  1. Explain what properties need to be configured in common_local.properties
  2. Document the purpose of each Maven command
  3. Add prerequisites and expected outcomes

Apply this diff to improve the documentation:

 ### 2. Database Schema Management Service Deployment
 
 #### Repository Configuration
 
 ```bash
 git clone https://github.com/PSMRI/AMRIT-DB.git
 cd AMRIT-DB

Setup instructions

-Follow these steps to setup datbase schema.
+Follow these steps to setup the database schema:
+
+1. Copy the example properties file:

cp src/main/environment/common_example.properties src/main/environment/common_local.properties 
+```
+
+2. Configure the properties file:
+   - Open `common_local.properties`
+   - Update database connection details to match your environment:
+     - `spring.datasource.url`
+     - `spring.datasource.username`
+     - `spring.datasource.password`
+
+3. Build and run the application:
+
+```bash
mvn clean install -DENV_VAR=local
mvn spring-boot:run -DENV_VAR=local

+Expected outcomes:
+- The build should complete successfully
+- The application should start and create/update database schemas
+- Check the logs for any errors during schema creation
+
+Troubleshooting:
+- Ensure MySQL is running and accessible
+- Verify database credentials in properties file
+- Check Maven and Java versions match requirements


</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 58f5c8d2e278661ea8a0299c9a86e9894ce6015e and 59d142d858c3d0122f938972dfa82ecf2a070861.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `amrit-local-setup/README.md` (2 hunks)
* `amrit-local-setup/loaddummydata.sh` (2 hunks)

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +16 to 29
# Iterate over the files and execute them
for i in $(seq 0 $((${#FILES[@]} - 1))); do
FILE="${FILES[$i]}"
DATABASE="${DATABASES[$i]}"
echo "Running $FILE on $DATABASE..."

mysql -h 127.0.0.1 -P 3306 -u root -p"$PASSWORD" "$DATABASE" < "$SQL_DIR/$FILE"
mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASSWORD" "$DATABASE" < "$SQL_DIR/$FILE"

if [ $? -eq 0 ]; then
echo "Successfully executed $FILE on $DATABASE."
else
echo "Error executing $FILE on $DATABASE."
fi
done
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve iteration logic and error handling.

The current implementation has a few potential issues:

  1. seq command isn't guaranteed in all sh implementations
  2. Error messages could be more informative
  3. No overall status tracking

Apply this diff to improve robustness:

-# Iterate over the files and execute them
-for i in $(seq 0 $((${#FILES[@]} - 1))); do
-    FILE="${FILES[$i]}"
-    DATABASE="${DATABASES[$i]}"
+# Track overall success
+SUCCESS=true
+
+# Process each mapping from config
+while IFS=: read -r FILE DATABASE; do
+    # Skip empty lines and comments
+    [ -z "$FILE" ] || [ "${FILE#\#}" != "$FILE" ] && continue
+
     echo "Running $FILE on $DATABASE..."
     
-    mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASSWORD" "$DATABASE" < "$SQL_DIR/$FILE"
+    # Validate file exists
+    if [ ! -f "$SQL_DIR/$FILE" ]; then
+        echo "Error: SQL file $SQL_DIR/$FILE not found"
+        SUCCESS=false
+        continue
+    }
+
+    # Execute with detailed error output
+    ERROR_LOG=$(mktemp)
+    if ! mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASSWORD" "$DATABASE" < "$SQL_DIR/$FILE" 2>"$ERROR_LOG"; then
+        echo "Error executing $FILE on $DATABASE:"
+        cat "$ERROR_LOG"
+        rm "$ERROR_LOG"
+        SUCCESS=false
+        continue
+    fi
+    rm "$ERROR_LOG"
 
-    if [ $? -eq 0 ]; then
-        echo "Successfully executed $FILE on $DATABASE."
-    else
-        echo "Error executing $FILE on $DATABASE."
-    fi
-done
+    echo "Successfully executed $FILE on $DATABASE."
+done < "$CONFIG_FILE"
+
+# Exit with appropriate status
+if [ "$SUCCESS" = true ]; then
+    echo "All files processed successfully."
+    exit 0
+else
+    echo "Some files failed to process. Please check the errors above."
+    exit 1
+fi

Committable suggestion skipped: line range outside the PR's diff.

@drtechie
Copy link
Member Author

@Asp-irin made a few changes.
Can you please checkout this document-update branch and see if everything works fine for you?

@Asp-irin
Copy link
Contributor

Asp-irin commented Jan 28, 2025

@drtechie
I hope we can close this PR we had merged a PR for this!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (3)
Jenkinsfile (3)

1-6: Define and validate the project parameter
The project choice parameter is useful but lacks validation for missing or unsupported values. Consider adding a default, grouping environments into a map, and validating params.project early to fail fast on invalid selections.


578-615: Remove or formalize commented-out Helpline1097-UI stage
The large commented block for Helpline1097-UI clutters the pipeline and risks bit rot. If it’s not needed, delete it. Otherwise, convert it into a parameterized or toggleable stage so it can be enabled via configuration, not manual commenting.


892-901: Validate artifact presence before deployment
Before invoking scp, add a check to confirm that TARGET_DIR contains .war files. If no artifacts are found, fail the build or emit a clear warning to avoid silent deployment of empty directories.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59d142d and 6288f96.

📒 Files selected for processing (1)
  • Jenkinsfile (1 hunks)
🔇 Additional comments (1)
Jenkinsfile (1)

8-12: Verify Jenkins tool installation names
Ensure that 'JDK_17', 'NODE_20', and 'MAVEN_3.9.8' match the tool names configured in your Jenkins global tool configuration to avoid runtime errors.

Comment on lines +617 to +876
stage('Admin-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Admin-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('BeneficiaryID-Generation-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/BeneficiaryID-Generation-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Pbengenapi -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('Common-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Common-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('ECD-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/ECD-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('FHIR-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/FHIR-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('Helpline104-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Helpline104-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('Helpline1097-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Helpline1097-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('Identity-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Identity-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"


}
}
}

stage('HWC-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/HWC-API.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"
}

}
}

stage('Scheduler-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Scheduler-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('Inventory-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Inventory-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('MMU-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/MMU-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('TM-API') {

steps {
dir('repos') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/TM-API.git',
credentialsId: ''
]]
])
sh 'mvn clean package -DENV_VAR=ci -Dmaven.test.skip -e'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Factor API build stages into reusable logic
The API stages (from Admin-API to TM-API) mirror each other in checkout, Maven invocation, and artifact handling. Extract common behavior into a function or shared library to apply consistent flags (-Dmaven.test.skip, profiles), reduce boilerplate, and simplify future maintenance.

Comment on lines +878 to +889
stage('Undeploy All') {
steps {
script {


// Delete all files in the remote folder
sh '''
sshpass -p "${WILDFLY_PASSWORD}" ssh -o StrictHostKeyChecking=no ${WILDFLY_USER}@${WILDFLY_HOST} "del /q ${REMOTE_DEPLOY_DIR}\\*"
'''
}
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use Jenkins SSH credentials instead of sshpass
Passing passwords via sshpass and disabling StrictHostKeyChecking is insecure. Leverage the Jenkins SSH Agent or SSH Credentials Binding plugin to manage keys or passwords, remove -o StrictHostKeyChecking=no, and adhere to best security practices.

Comment on lines +232 to +236
} else if (params.project == 'Dev') {
} else if (params.project == 'UAT') {

}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implement or guard unconfigured Dev and UAT branches
The else if blocks for Dev and UAT are empty, leading to missing configuration when those environments are selected. Either populate these blocks with the correct settings or add a guard clause to error out if an unsupported environment is chosen.

Comment on lines +30 to +232
if (params.project == 'CICD_Test') {


env.WILDFLY_HOST = 'IP'
env.WILDFLY_USER = 'USER'
withCredentials([string(credentialsId: 'USER1', variable: 'WILDFLY_PASSWORD')]) {
env.WILDFLY_PASSWORD=WILDFLY_PASSWORD
}
env.TARGET_DIR = 'target'
env.REMOTE_DEPLOY_DIR='E:\\AppServer\\wildfly-30.0.0.Final\\wildfly-30.0.0.Final\\standalone\\deployments'
env.REMOTE_DEPLOY_DIR2='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/standalone/deployments'

env.COMMON_API="https://amritdemo.piramalswasthya.org/commonapi-v3.0.0/"
env.COMMON_API_BASE="https://amritdemo.piramalswasthya.org/commonapi-v3.0.0/"
env.COMMON_API_BASE_URL="https://amritdemo.piramalswasthya.org/commonapi-v3.0.0/"


env.ADMIN_API="https://amritdemo.piramalswasthya.org/adminapi-v3.0.0/"
env.ADMIN_API_BASE="https://amritdemo.piramalswasthya.org/adminapi-v3.0.0/"
env.ADMIN_API_BASE_URL="https://amritdemo.piramalswasthya.org/adminapi-v3.0.0/"

env.ECD_API="https://amritdemo.piramalswasthya.org/ecdapi/"
env.ECD_API_BASE="https://amritdemo.piramalswasthya.org/ecdapi/"
env.ECD_API_BASE_URL="https://amritdemo.piramalswasthya.org/ecdapi/"

env.COMMON_API_OPEN="https://amritdemo.piramalswasthya.org/commonapi-v3.0.0/"

env.INVENTORY_API="https://amritdemo.piramalswasthya.org/Inventoryapi-v3.0.0/"
env.INVENTORY_API_BASE="https://amritdemo.piramalswasthya.org/Inventoryapi-v3.0.0/"
env.INVENTORY_API_BASE_URL="https://amritdemo.piramalswasthya.org/Inventoryapi-v3.0.0/"

env.MMU_API="https://amritdemo.piramalswasthya.org/mmuapi-v3.0.0/"
env.MMU_API_BASE="https://amritdemo.piramalswasthya.org/mmuapi-v3.0.0/"
env.MMU_API_BASE_URL="https://amritdemo.piramalswasthya.org/mmuapi-v3.0.0/"

env.FHIR_API="https://amritdemo.piramalswasthya.org/fhirapi-v3.0.0/"
env.FHIR_API_BASE="https://amritdemo.piramalswasthya.org/fhirapi-v3.0.0/"
env.FHIR_API_BASE_URL="https://amritdemo.piramalswasthya.org/fhirapi-v3.0.0/"

env.SCHEDULER_API="https://amritdemo.piramalswasthya.org/schedulerapi-v3.0.0/"
env.SCHEDULER_API_BASE="https://amritdemo.piramalswasthya.org/schedulerapi-v3.0.0/"
env.SCHEDULER_API_BASE_URL="https://amritdemo.piramalswasthya.org/schedulerapi-v3.0.0/"

env.TM_API="https://amritdemo.piramalswasthya.org/tmapi-v3.0.0/"
env.TM_API_BASE="https://amritdemo.piramalswasthya.org/tmapi-v3.0.0/"
env.TM_API_BASE_URL="https://amritdemo.piramalswasthya.org/tmapi-v3.0.0/"

env.HWC_API="https://amritdemo.piramalswasthya.org/hwc-facility-service-v3.0.0/"
env.HWC_API_BASE="https://amritdemo.piramalswasthya.org/hwc-facility-service-v3.0.0/"
env.HWC_API_BASE_URL="https://amritdemo.piramalswasthya.org/hwc-facility-service-v3.0.0/"

env.GRIEVANCE_API_BASE_URL="https://grievance1097naco.piramalswasthya.org"
env.GRIEVANCE_USERNAME=""
env.GRIEVANCE_PASSWORD=""
env.GRIEVANCE_USER_AUTHENTICATE=""
env.GRIEVANCE_DATA_SYNC_DURATION=15
env.SESSION_STORAGE_ENC_KEY=""
env.JWT_SECRET_KEY=""

env.SERVER_IP=""
env.SWYMED_IP="IP"
env.COMMON_API_OPEN_SYNC="https://amritdemo.piramalswasthya.org/commonapi-v3.0.0/"
env.SCHEDULER_UI="https://amritdemo.piramalswasthya.org/hwc-scheduler/"
env.INVENTORY_UI="https://amritdemo.piramalswasthya.org/hwc-inventory/"

env.IDENTITY_API="https://amritdemo.piramalswasthya.org/identity-v3.0.0/"
env.IDENTITY_API_BASE="https://amritdemo.piramalswasthya.org/identity-v3.0.0/"
env.IDENTITY_API_BASE_URL="https://amritdemo.piramalswasthya.org/identity-v3.0.0/"

env.HELPLINE104_API="https://amritdemo.piramalswasthya.org/104api-v3.0.0/"
env.HELPLINE104_API_BASE="https://amritdemo.piramalswasthya.org/104api-v3.0.0/"
env.MMU_UI="https://amritdemo.piramalswasthya.org/mmu"
env.IOT_API=""
env.DATABASE_URL="jdbc:mysql://localhost:3306/db_iemr?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
env.DATABASE_USERNAME="dbuser"
withCredentials([string(credentialsId: 'DB_PASS_CICD_TEST', variable: 'DATABASE_PASSWORD')]) {
env.DATABASE_PASSWORD=DATABASE_PASSWORD
}
env.DATABASE_IDENTITY_URL="jdbc:mysql://localhost:3306/db_identity?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
env.DATABASE_1097_IDENTITY_URL="jdbc:mysql://localhost:3306/db_1097_identity?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
env.DATABASE_IDENTITY_USERNAME="dbuser"
withCredentials([string(credentialsId: 'DATABASE_IDENTITY_PASSWORD_CICD_TEST', variable: 'DATABASE_IDENTITY_PASSWORD')]) {
env.DATABASE_IDENTITY_PASSWORD=DATABASE_IDENTITY_PASSWORD
}
env.CALLCENTRE_SERVER_IP="IP"
withCredentials([string(credentialsId: 'SWYMED_APIKEY_CICD_TEST', variable: 'SWYMED_APIKEY')]) {
env.SWYMED_APIKEY=SWYMED_APIKEY
}
env.SWYMED_BASE_URL="https://psmri.swymed.com:9274"
env.REPORTING_DATABASE_USERNAME="dbuser"
withCredentials([string(credentialsId: 'REPORTING_DATABASE_PASSWORD_CICD_TEST', variable: 'REPORTING_DATABASE_PASSWORD')]) {
env.REPORTING_DATABASE_PASSWORD=REPORTING_DATABASE_PASSWORD
}
env.REPORTING_DATABASE_URL="jdbc:mysql://localhost:3306/db_reporting?autoReconnect=true&useSSL=false"
env.KM_API_BASE_URL="http://localhost:8084/OpenKM"
env.KM_API_BASE_PATH="localhost:8084/OpenKM"
env.CTI_SERVER_IP="IP"
env.CTI_SERVER_LOGGER_BASE="http://IP/logger"
env.IDENTITY_API_URL="http://localhost:8080/identity-v3.0.0"
env.IDENTITY_1097_API_URL="http://localhost:8080/1097identityapi-v3.0.0"
env.BEN_GEN_API_URL="http://localhost:8080/bengenapi-v3.0.0"
env.MMU_API="http://localhost:8080/mmuapi-v3.0.0"

env.MMU_CENTRAL_SERVER="http://localhost:8080/mmuapi-v3.0.0"
env.TM_CENTRAL_SERVER="http://localhost:8080/tmapi-v3.0.0"
env.SCHEDULER_API="http://localhost:8080/schedulerapi-v3.0.0"
withCredentials([string(credentialsId: 'FETOSENSE_API_KEY_CICD_TEST', variable: 'FETOSENSE_API_KEY')]) {
env.FETOSENSE_API_KEY=FETOSENSE_API_KEY
}

env.TM_API="http://localhost:8080/telemedicineapi-v1.0"
env.SERVICE_POINT_ID= 235
env.PARKING_PLACE_ID= 233
env.PROVIDER_SERVICE_MAP_ID= 1261
env.VAN_ID= 220
env.SERVICE_ID= 4
env.PROVIDER_ID= 500
env.APP_ID= 85696
env.AUTH_KEY= ""
env.AUTH_SECRET= ""
env.MMU_FILE_BASE_PATH="C:/apps/Neeraj/mmuDoc"
env.HWC_IDENTITY_API=""
env.FILE_SYNC_SERVER_IP=""
env.FILE_SYNC_SERVER_DOMAIN=""
env.FILE_SYNC_SERVER_USERNAME=""
env.FILE_SYNC_SERVER_PASSWORD=""
env.LOCAL_FOLDER_TO_SYNC=""
env.SEND_SMS="TRUE"
env.CARESTREAM_SOCKET_IP="IP"
env.CARESTREAM_SOCKET_PORT="1235"
env.SEND_SMS_URL="http://localhost:8080/commonapi-v3.0.0/sms/sendSMS"
env.SMS_USERNAME=""
withCredentials([string(credentialsId: 'SMS_PASSWORD_CICD_TEST', variable: 'SMS_PASSWORD')]) {
env.SMS_PASSWORD=SMS_PASSWORD
}
env.SMS_SOURCE_ADDRESS=""
env.SMS_MESSAGE_URL="https://openapi.airtel.in/gateway/airtel-iq-sms-utility/sendSingleSms"
env.SEND_EMAIL=""
env.MAIL_HOST=""
env.MAIL_PORT=""
env.MAIL_USERNAME=""
env.MAIL_PASSWORD=""
env.EVERWELL_USERNAME=""
env.EVERWELL_PASSWORD=""
env.EVERWELL_AMRIT_USERNAME=""
env.EVERWELL_AMRIT_PASSWORD=""
env.EVERWELL_BASE_URL=""
env.SWAASA_EMAIL=""
env.SWAASA_PASSWORD=""
env.ESANJEEVANI_URL=""
env.ESANJEEVANI_USERNAME=""
env.ESANJEEVANI_PASSWORD=""
env.ESANJEEVANI_SALT=""
env.ESANJEEVANI_SOURCE=""
env.ESANJEEVANI_REGISTER_PATIENT_URL=""
env.ESANJEEVANI_ROUTE_URL=""
env.BIOMETRIC_URL=""
env.EAUSHADHI_URL=""
env.FHIR_USER_NAME=""
env.FHIR_PASSWORD=""
env.MONGO_HOST="IP"
env.MONGO_AUTH_DBNAME=""
env.MONGO_DBNAME=""
env.MONGO_USERNAME=""
withCredentials([string(credentialsId: 'MONGO_PASSWORD_CICD_TEST', variable: 'MONGO_PASSWORD')]) {
env.MONGO_PASSWORD=MONGO_PASSWORD
}
env.BAHMINI_URL=""
env.FEED_AUTH_URL=""
env.FEED_AUTH_PASSWORD=""
env.NDHM_ABHA_CLIENT_ID=""
env.NDHM_ABHA_CLIENT_SECRET_KEY=""
env.ABDM_BASE_URL="https://abhasbx.abdm.gov.in"
env.ABDM_HEALTH_ID_BASE_URL="https://healthidsbx.abdm.gov.in"

env.NHM_AGENT_REAL_TIME_DATA_URL="http://IP/apps/utility/alive_api.php"

env.BASE_URL = 'AnotherValueForType1'
env.TERM='xterm'
env.COMMON_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/common-api.log'
env.ADMIN_UI_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/admin-ui.log'
env.ADMIN_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/admin-api.log'
env.HELPLINEMCTS_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/helplinemcts-api.log'
env.TM_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/tm-api.log'
env.FHIR_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/fhir-api.log'
env.IDENTITY_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/identity-api.log'
env.HWC_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/hwc-api.log'
env.INVENTORY_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/inventory-api.log'
env.BENEFICIARYID_GENERATION_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/beneficiaryid-generation-api.log'
env.HELPLINE104_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/helpline104-api.log'
env.MMU_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/mmu-api.log'
env.HELPLINE1097_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/helpline1097-api.log'
env.SCHEDULER_UI_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/scheduler-ui.log'
env.SCHEDULER_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/scheduler-api.log'
env.ECD_API_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/ecd-api.log'
env.ECD_UI_LOGGING_FILE_NAME='E:/AppServer/wildfly-30.0.0.Final/wildfly-30.0.0.Final/Logs/ecd-ui.log'

env.SWAGGER_DOC_ENABLED='true'




} else if (params.project == 'Dev') {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Externalize and DRY environment configuration
Embedding over 200 lines of environment variable assignments for CICD_Test makes this stage very hard to review and maintain. Consider:

  • Loading these settings from an external YAML/JSON configuration.
  • Defining a single Map in Groovy for each environment.
  • Iterating over the map to assign env.* values.
    This will reduce duplication, simplify updates, and make adding new environments trivial.

Comment on lines +18 to +28
stage('Load Environment Variables') {
steps {
echo "Setting environment variables based on the selected project"

script {

sh "rm -rf ${env.WORKSPACE}/repos"
sh "mkdir -p ${env.WORKSPACE}/repos"
sh "rm -rf ${env.WORKSPACE}/target "
sh "mkdir -p ${env.WORKSPACE}/target"

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace shell cleanup with Jenkins workspace steps
Using sh "rm -rf ..." and sh "mkdir -p ..." is error-prone and platform-dependent. Prefer deleteDir() or the cleanWs() pipeline step to reset the workspace and manage directories in a more Jenkins-native way.

Comment on lines +243 to +576
stage('Admin-UI') {

steps {
dir('repos'){


cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/ADMIN-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}





stage('ECD-UI') {

steps {
dir('repos'){


cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/ECD-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}


stage('HWC-Inventory-UI') {

steps {
dir("${env.WORKSPACE}/repos") {

cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/HWC-Inventory-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
sh 'npm config set legacy-peer-deps true'
sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "echo ${env.WORKSPACE}"

sh " cp target/*.war ${env.WORKSPACE}/target/ "

}
}
}

stage('HWC-Scheduler-UI') {

steps {
dir('repos') {

cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/HWC-Scheduler-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"
}

}
}

stage('HWC-UI') {

steps {
script {

dir('repos/') {
cleanWs()


checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/HWC-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

}
dir('repos/Common-UI') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Common-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

}
dir('repos/') {

sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}
}

stage('Inventory-UI') {

steps {
dir('repos'){


cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Inventory-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('MMU-UI') {

steps {
script {

dir('repos/') {
cleanWs()


checkout([$class: 'GitSCM',
branches: [[name: 'feature/test']],
userRemoteConfigs: [[
url: 'git@github.com:psmri/MMU-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

}
dir('repos/Common-UI') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:psmri/Common-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

}
dir('repos/') {

sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}
}

stage('Scheduler-UI') {

steps {
dir('repos'){


cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Scheduler-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}

stage('TM-UI') {

steps {
script {

dir('repos/') {
cleanWs()


checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/TM-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

}
dir('repos/Common-UI') {

checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Common-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])

}
dir('repos/') {
sh 'git submodule init'
sh 'git submodule update --recursive'
sh 'npm install --force'
sh 'npm run build-ci'
sh 'mvn -B package --file pom.xml -P ci'
archiveArtifacts 'target/*.war'
sh "cp target/*.war ${env.WORKSPACE}/target/"

}
}
}
}

stage('Helpline104-UI') {

steps {
dir('repos'){


cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: 'develop']],
userRemoteConfigs: [[
url: 'git@github.com:PSMRI/Helpline104-UI.git',
credentialsId: '' // Specify your SSH credentials ID
]]
])
script {
// sh 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash'
sh '''
export NVM_DIR="/var/lib/jenkins/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
git submodule init
git submodule update --recursive
nvm install 14
nvm use 14
npm i
npm run build
'''
sh '''
cd dist/
mkdir WEB_INF/
touch WEB_INF/web.xml
jar -cvf Helpline104.war *
'''
archiveArtifacts 'dist/*.war'
sh "cp dist/*.war ${env.WORKSPACE}/target/"
}

}
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Abstract repetitive UI build stages and enable parallelism
Each UI project—from Admin-UI through Helpline104-UI—repeats the same checkout, build, and archive steps. You can:

  1. Define a list of UI repos and loop over them.
  2. Encapsulate the logic in a shared library or helper method.
  3. Use a parallel {} block to run independent UI builds concurrently and reduce overall pipeline duration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants