Draft
Conversation
Contributor
Author
🔧 SonarScanner Java Detection Issue - Resolution SummaryProblem OverviewDuring the Root Cause AnalysisThe issue stemmed from environment variable propagation problems between PowerShell and child .NET processes in Docker containers:
Resolution Path✅ Final Solution (Commits:
|
The previous commit introduced bash && operators which are not valid PowerShell syntax. PowerShell requires semicolons (;) to chain commands. This fixes the parser error: 'Unexpected token '=' in expression or statement' All command separators in the test task now use PowerShell-compatible semicolons instead of bash && operators.
The previous approach of setting $env:JAVA_HOME and $env:PATH was not propagating to child processes spawned by .NET tools (dotnet-sonarscanner). This commit uses [System.Environment]::SetEnvironmentVariable() with Process scope to ensure JAVA_HOME and PATH are properly inherited by all child processes in the PowerShell session, including the SonarScanner CLI invoked by dotnet-sonarscanner. Key changes: - Use SetEnvironmentVariable with Process target instead of $env: syntax - Set environment variables once at the start of the test task - Remove redundant re-setting before Invoke-SonarScanner -stop - Add diagnostic output to verify variables are set correctly
Set SONAR_SCANNER_JAVA_OPTS with -Djava.home to tell the SonarScanner JVM directly where Java is installed, bypassing PATH lookup issues. Also added diagnostic output to show which java executable is being resolved, and ensured JAVA_HOME/PATH are set before both start and stop operations. This approach passes the Java location as a JVM system property which should work even if environment variable inheritance to child processes is problematic.
- Remove /usr/local/java/bin/java and create symlink to correct Java 17 - This ensures SonarScanner CLI finds the correct Java regardless of PATH - Eliminates environment variable propagation issues through process chain - Removes diagnostic output and redundant env var settings
…werShell PowerShell in the container doesn't recognize sudo or native shell commands like ln. This fix wraps the symlink commands in 'sh -c' to execute them in a proper shell environment where these commands are available.
Created detailed documentation analyzing the persistent Java detection failure in eirctl Docker containers during the taskctl to eirctl migration. Document includes: - Problem statement with technical root cause analysis - Detailed breakdown of 10 remediation attempts with commit links - Architecture analysis of process chains and environment propagation - 7 proposed solutions with implementation details and risk assessment - Comparison matrix and recommended hybrid approach - Investigation checklist and lessons learned - Complete references and build log excerpts This 31-page document serves as a comprehensive resource for: - Understanding the multi-level environment variable inheritance issue - Evaluating solution options (container fix, context config, bash scripts) - Planning the path forward to unblock the eirctl migration Related: PR #741
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



[XXXX-<Title> - Please use the Work Item number and Title as PR Name, not subtasks]
📲 What
Migration from
taskctltoeirctlbased upon eirctl migration guide.🤔 Why
Usage of
taskctlis deprecated within Ensono Digital.🛠 How
Following steps in: https://github.com/Ensono/eirctl/blob/docs/migration/docs/migration.adoc
👀 Evidence
🕵️ How to test
Notes for QA
✅ Acceptance criteria Checklist