title: GitLab CI secret variables for Gradle publish
body: <p>How to setup Gradle publish task user credentials with GitLab CI secret variables? I am using <a href="https://docs.gradle.org/current/userguide/publishing_maven.html" rel="noreferrer">gradle maven publish plugin</a>, and here is snippet from build.gradle</p>
  
  <pre><code>repositories {
      maven {
        credentials {
          username artifactUser
          password artifactPass
        }
        url "..."
      }
    }
  </code></pre>
  
  <p>I've tried to use <code>gradle.properties</code> as below</p>
  
  <pre><code>artifactUser=${env.MAVEN_REPO_USER}
  artifactPass=${env.MAVEN_REPO_PASS}
  </code></pre>
  
  <p>And several ways of accessing secret variables in <code>.gitlab-ci.yml</code> file (because gradle.properties is not picked up from gradle or variables are not transformed correctly, it is in root project dir)</p>
  
  <p>Method 1</p>
  
  <pre><code>'./gradlew publish -x test -PartifactUser=${env.MAVEN_REPO_USER} -PartifactPass=${env.MAVEN_REPO_PASS}'
  </code></pre>
  
  <p>Error: <code>/bin/bash: line 56: -PartifactUser=${env.MAVEN_REPO_USER}: bad substitution</code></p>
  
  <p>Method 2</p>
  
  <pre><code>    before_script:
        - chmod +x ./gradlew
        - export REPO_USER=${env.MAVEN_REPO_USER}
        - export REPO_PASS=${env.MAVEN_REPO_PASS}
      ...
      deploy:
    stage: deploy
    script:
      - ./gradlew publish -x test -PartifactUser=$REPO_USER -PartifactPass=$REPO_PASS
  </code></pre>
  
  <p>I am using <code>openjdk:8-jdk-slim</code> image for build using gradle wrapper. Seems like there are several <a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/27098" rel="noreferrer">issues</a> with this kind of variable usage, do we have any workaround?</p>