- Quick Commands for Production Maintenance
- Features
- How It Works
- Configuration
- File Structure
- Running the Server (Production & Development)
- Running with Docker Compose
- Deployment Instructions (Docker Compose)
- Docker Compose and Networking Notes
- Troubleshooting
This project is a Node.js/Bun-based server that keeps Zendesk ticket custom fields in sync with their corresponding JIRA issues. It is designed to ensure that Zendesk tickets always reflect the latest state of their linked JIRA issues, such as type, resolution, and fix versions.
To start the production server:
docker compose up --build -d jira-zendesk-prodTo stop the production server:
docker compose down- Automatic Polling:
- Polls Zendesk for tickets with JIRA links and fetches the latest JIRA issue data.
- Runs two intervals:
- Every 30 seconds: Syncs recently changed tickets and JIRAs.
- Every 30 minutes: Performs a full sync to catch any missed updates.
- Efficient Updates:
- Uses a cache to avoid unnecessary updates.
- Only updates Zendesk tickets if the JIRA issue's type, resolution, or fix versions have changed.
- Custom Field Mapping:
- Maps JIRA fields to Zendesk custom fields (IDs are configurable via environment variables).
- Error Logging:
- Logs errors and sync activity for monitoring and debugging.
-
Startup:
- Logs environment info.
- Performs an initial full sync.
- Starts two polling intervals (recent and full sync).
-
Polling:
- Fetches Zendesk tickets that are not closed and have a JIRA key set.
- Extracts JIRA keys and fetches the corresponding JIRA issues.
- If running a recent sync, also fetches recently changed JIRAs and merges them.
-
Syncing:
- Compares each JIRA issue with the cached version.
- If a JIRA issue is new or has changed, updates the cache and marks it for update.
- Finds Zendesk tickets referencing updated JIRAs and updates their custom fields.
Set the following environment variables in .env.production and .env.development based on the usage. Do not commit files with secrets. For sharing variable names, use a .env.example file:
ZENDESK_DOMAIN- Zendesk API base URLZENDESK_EMAIL- Zendesk user emailZENDESK_APITOKEN- Zendesk API tokenJIRA_DOMAIN- JIRA API base URLJIRA_TOKEN- JIRA API tokenJIRA_OR_GITHUB_CUSTOM_FIELD_ID- Zendesk custom field ID for JIRA keyJIRA_TYPE_FIELD_ID- Zendesk custom field ID for JIRA typeJIRA_RESOLUTION_FIELD_ID- Zendesk custom field ID for JIRA resolutionJIRA_FIX_VERSIONS_FIELD_ID- Zendesk custom field ID for JIRA fix versions
Refer to http://nuoconfluence/display/SERVICES/JIRA+-+Zendesk+Sync+Server for default/example values.
index.ts- Main server logic and polling/sync orchestrationzendesk.ts- Zendesk API client and helpersjira.ts- JIRA API client and helperslog.ts- Logging utilitieslogs/- Server log fileshealth-check.ts- Health check scripttests/- Test suite (with mocks and helpers)docker-compose.yml- Docker Compose configurationDockerfile- Docker build instructions.env.*- Environment variable files
- The
jira-zendesk-dev,jira-zendesk-prod, andjira-zendesk-testservices are defined in yourdocker-compose.yml. - Use the appropriate
.envfile for each environment (e.g.,.env.developmentfor dev,.env.productionfor prod,.env.testfor test).
To run the production server:
bun startOr, with Docker Compose:
# Start the production service in the background
# (add --build to force a rebuild)
docker compose up --build -d jira-zendesk-prod
# View logs
docker compose logs -f jira-zendesk-prodTo run the development server (with hot reload, debug, or dev-specific settings):
bun devOr, with Docker Compose:
# Start the development service in the background
docker compose up --build -d jira-zendesk-dev
# View logs
docker compose logs -f jira-zendesk-devTo run tests, you should first start the development server (so that any required services or dependencies are available):
Without Docker Compose:
bun dev
# In another terminal:
bun testWith Docker Compose:
# Start the development server (if not already running)
docker compose up --build -d jira-zendesk-dev
# Then run tests
docker compose run --rm jira-zendesk-testYou can verify that your environment variables and API credentials are correct and that both JIRA and Zendesk APIs are reachable.
NODE_ENV=development bun health-check
NODE_ENV=production bun health-checkdocker compose run -e NODE_ENV=development --rm jira-zendesk-health
docker compose run -e NODE_ENV=production --rm jira-zendesk-healthThis will attempt to connect to both APIs using the current environment and print the result to the console. Set NODE_ENV as needed for your environment.
- Ensure you have Docker and Docker Compose installed.
- Copy
.env.exampleto.env.productionand/or.env.developmentand fill in the required values. - Use
docker compose up --build -d <service>to start a service in detached mode. - Use
docker compose logs -f <service>to follow the logs of a service.
-
Prepare Environment Variables:
- Copy the example environment file:
cp .env.example .env.production - Edit
.env.productionto set your production values.
- Copy the example environment file:
-
Build and Start Services:
- Run
docker compose up --build -d jira-zendesk-prodto build and start the production services.
- Run
-
Monitor Logs:
- Use
docker compose logs -f jira-zendesk-prodto monitor the logs for any issues.
- Use
-
Verify Deployment:
- Check the health of the services and verify that the application is working as expected.
- Docker Compose creates a default network for your application. All services are connected to this network and can communicate with each other using the service name as the hostname.
- If you need to connect to external services (like databases or APIs), ensure that the necessary ports are exposed and any required environment variables are set.
- For development, you might want to use
docker compose up --buildto rebuild the images when code changes. For production, usedocker compose up -dto start the services in detached mode.
- Log files not created: Ensure the
logs/directory exists and is writable by the container. If using Docker Compose, check volume permissions. - Environment variables not loaded: Make sure you have the correct
.env.*file for your environment and it is in the project root. - Docker image not rebuilding: Use
docker compose up --build -d ...to force a rebuild. - Permission errors: If you see file or directory permission errors, check your Docker volume mappings and user permissions.