GitLab CI secret variables for Gradle publish

后端 未结 3 1868
臣服心动
臣服心动 2021-02-20 14:39

How to setup Gradle publish task user credentials with GitLab CI secret variables? I am using gradle maven publish plugin, and here is snippet from build.gradle

         


        
3条回答
  •  攒了一身酷
    2021-02-20 15:32

    You don't need env. prefinx in your .gitlab-ci.yml. You don't need to re-export the variables as well.

    If you have defined a variables named MAVEN_REPO_USER and MAVEN_REPO_PASS in Gitlab CI/CD settings for the project, you can just use them in Gradle script:

    repositories {
        maven {
            credentials {
                username System.getenv("MAVEN_REPO_USER")
                password System.getenv("MAVEN_REPO_PASS")
            }
            url "…"
        }
    }
    

提交回复
热议问题