Test case environment assignments not syncing to staging env

We’re running Xray Test Management on Jira 9 and hitting a critical sync issue with environment assignments. Test cases configured for staging environment aren’t propagating correctly when triggered from our CI pipeline.

The Xray environment custom field shows “Staging” in Jira UI, but when CI parameters pass the environment flag, test executions default to “Dev” instead. We’ve verified the OSLC adapter configuration includes environment mapping, but something’s breaking the chain.


POST /rest/raven/1.0/import/execution
Environment: "staging"
Result: Execution created with env="dev"

This blocks our QA validation workflow since test results are being tagged to wrong environment. Has anyone resolved environment field sync issues between Xray custom fields and CI-triggered executions?

I’ve seen this exact behavior. The issue is usually that Xray’s environment field and the REST API environment parameter are two separate concepts. The custom field in Jira is for display, but the API expects a specific environment ID, not the label.

Check your Xray environment configuration under Test Environments settings. Each environment has an internal ID that must match what your CI pipeline sends. The label mismatch causes the fallback to default environment.

We had similar issues with custom field sync. The problem was that our CI pipeline was setting the environment parameter in the import request, but the custom field on the Test Execution issue wasn’t being populated automatically. We had to add a separate API call after execution creation to explicitly set the custom field value using the Jira REST API, not just the Xray import endpoint. It’s a two-step process unfortunately.

Excellent troubleshooting thread. Let me provide the comprehensive solution that addresses all the environment sync components:

1. Xray Environment Mapping Fix: First, standardize your environment names in Xray Test Environments configuration. Ensure they match exactly (case-sensitive) with what your CI passes. Navigate to Xray settings → Test Environments and verify each environment name.

2. Custom Field Sync Configuration: The environment custom field needs explicit mapping. Add this to your CI script:


curl -X PUT /rest/api/2/issue/{executionKey} \
  -d '{"fields": {"customfield_10050": "Staging"}}'

Replace customfield_10050 with your actual environment field ID. This ensures the Jira custom field reflects the execution environment.

3. CI Parameter Passing: Update your pipeline to use exact environment names:


xray_import_execution(
  environment="Staging",
  testPlanKey="TP-123"
)

Not lowercase, not IDs - exact string match to Xray configuration.

4. OSLC Adapter Configuration: If using OSLC Connect or similar adapters, check the adapter’s environment mapping rules. Edit the adapter configuration file to remove hardcoded environment overrides:


# Remove or comment out:
# environment.default=dev
# environment.override=true

Set environment.passthrough=true to allow CI parameters to flow through.

5. Verification Steps:

  • Create a test execution via API and immediately query the custom field value
  • Check Xray execution details page to confirm environment badge matches
  • Review CI logs for any environment parameter warnings
  • Test with all three environments to ensure consistent behavior

Additional Considerations: If you’re using Xray Cloud, note that environment handling differs slightly from Server/DC. Cloud uses a different API endpoint structure. Also, ensure your CI service account has permission to set custom fields - some organizations restrict this.

The key insight is that environment data flows through three layers: Xray’s internal environment registry, the API import parameters, and the Jira custom field. All three must align for proper sync. Most sync failures occur when one layer has different naming conventions or override rules.

After implementing these changes, your staging environment assignments should sync correctly, and QA validation workflows will reflect accurate environment tagging. The fix typically takes effect immediately without requiring Jira restart.

You need to pass the environment name exactly as configured in Xray, not the ID. The API accepts environment names but they’re case-sensitive. I bet your Xray config has “Staging” with capital S, but your CI is sending lowercase “staging”.

Also verify your OSLC adapter settings if you’re using external test management tools. The adapter might have its own environment mapping that overrides the direct API parameters.

I found the root cause - it was a combination of case sensitivity and OSLC adapter configuration. Our adapter had a hardcoded environment mapping that was overriding the CI parameters. After reviewing the suggestions here, I implemented a complete fix.