Shared Repo/Deploy key between CI and Developers w/ Gradle

For context, here’s the current (relevant) build.gradle information.

ext {
    nexusUsername = "$System.env.NEXUS_USERNAME"
    nexusPassword = "$System.env.NEXUS_PASSWORD"
}

repositories {
    maven {
        url "https://repo.qixalite.com/repository/Qixalite-Private"
        credentials {
            username nexusUsername
            password nexusPassword
        }
    }
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "https://repo.qixalite.com/repository/qixalite-private-releases/") {
                authentication(userName: nexusUsername, password: nexusPassword)
            }
            snapshotRepository(url: "https://repo.qixalite.com/repository/qixalite-private-snapshot/") {
                authentication(userName: nexusUsername, password: nexusPassword)
            }
        }
    }
}

Because GitLab-CI’s runners are containerized we cannot use our normal method of putting the username/password inside of GRADLE_HOME. Short of creating a custom docker container, obviously.

So our current system is that we have environmental variables setup (GitLab-CI through the project, developers through their own system) which have their username/passwords for the repository.

Users are allowed to pull from the repo, while the CI is using a username/password that allows it to deploy to the repo.

I’m curious if there is a better way to do this because a few of my developers have mentioned how dirty the current method feels.

Any help is appreciated! <3

From Gradle docs: "
If the environment variable name looks like ORG_GRADLE_PROJECT_prop=somevalue, then Gradle will set a prop property on your project object, with the value of somevalue. Gradle also supports this for system properties, but with a different naming pattern, which looks like org.gradle.project.prop."

so your env variable has to follow naming convention ORG_GRADLE_PROJECT_ and then gradle will recognized it and it will be visible in your build.gradle file