Skip to content

fix: Update System.env syntax for Gradle 9 compatibility#140

Merged
sam-herman merged 1 commit into
opensearch-project:mainfrom
dbwiddis:fix-gradle-9-syntax
Aug 26, 2025
Merged

fix: Update System.env syntax for Gradle 9 compatibility#140
sam-herman merged 1 commit into
opensearch-project:mainfrom
dbwiddis:fix-gradle-9-syntax

Conversation

@dbwiddis
Copy link
Copy Markdown
Member

This PR updates the Gradle build files to fix compatibility with Gradle 9.

Problem

The current syntax using $System.env.VARIABLE_NAME for accessing environment variables is not compatible with Gradle 9.

This format is used in this repository for Sonatype credentials for SNAPSHOT publication. This fails with under Gradle 9.

credentials {
    username = "$System.env.SONATYPE_USERNAME"
    password = "$System.env.SONATYPE_PASSWORD"
}

See example failed workflow here.

Solution

Update to use the System.getenv() method instead:

credentials {
    username = System.getenv("SONATYPE_USERNAME")
    password = System.getenv("SONATYPE_PASSWORD")
}

Example fix which restored successful snapshots: opensearch-project/opensearch-remote-metadata-sdk#245

Signed-off-by: Daniel Widdis <widdis@gmail.com>
@sam-herman
Copy link
Copy Markdown
Collaborator

thank you @dbwiddis !

@sam-herman sam-herman merged commit 0b070ad into opensearch-project:main Aug 26, 2025
11 of 42 checks passed
opensearch-trigger-bot Bot pushed a commit that referenced this pull request Aug 26, 2025
Signed-off-by: Daniel Widdis <widdis@gmail.com>
(cherry picked from commit 0b070ad)
sam-herman pushed a commit that referenced this pull request Aug 26, 2025
(cherry picked from commit 0b070ad)

Signed-off-by: Daniel Widdis <widdis@gmail.com>
Co-authored-by: Daniel Widdis <widdis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants