Configure access credentials for dependency downloads
During a build, your pipeline needs to download dependencies, requiring access credentials for your private repositories. To keep your credentials secure, Flow lets you configure them as environment variables. For credentials that are managed across your entire organization, we recommend using a general variable group instead.
Java
-
Add the URL, username, and password for your private repository to the
settings.xmlfile. Configure the username and password using environment variables.<servers> <server> <id>rdc-releases</id> <username>${MVN_USERNAME}</username> <password>${MVN_PASSWORD}</password> </server> <server> <id>rdc-snapshots</id> <username>${MVN_USERNAME}</username> <password>${MVN_PASSWORD}</password> </server> </servers> <profiles> <profile> <activation> <activeByDefault>true</activeByDefault> </activation> <id>rdc-private-repo</id> <repositories> <repository> <id>rdc-releases</id> <url>https://packages.aliyun.com/maven/repository/2000093-release/</url> </repository> <repository> <id>rdc-snapshots</id> <url>https://packages.aliyun.com/maven/repository/2000093-snapshot/</url> </repository> </repositories> </profile> </profiles>In the code sample, replace the content of the
<url>tag with the URL of your private repository. -
In your pipeline, configure environment variables for the Maven repository username and password.
Click the Variables tab in the top navigation bar. In the Configure Variable Group section, add two parameters:
MVN_USERNAMEandMVN_PASSWORD. Set their default values to your Maven repository username and password, respectively. Then, enable private mode for both. -
Use the
settings.xmlfile in your pipeline command.Add the
-s settings.xmlargument to your Maven command to specify the custom configuration file. For example:mvn test -s settings.xml.
NPM and Golang
-
In the pipeline, configure environment variables for your username and password.
Add the
GIT_USERNAMEandGIT_PASSWORDvariables, and enable the private option for both. -
Before you run
npm installorgo get, add the following command:git config --global url."https://${GIT_USERNAME}:${GIT_PASSWORD}@codeup.aliyun.com".insteadOf "https://codeup.aliyun.com"For NPM, go to the NPM Build step. In the command editor, add the
git configcommand before you runnpm install. For Golang, go to the Pipeline Configuration page. In the Build stage, open the Golang Build step. In the command editor, configure theGOPROXYandGOPRIVATEenvironment variables, then add thegit configcommand before thego getcommand.The
GIT_USERNAMEandGIT_PASSWORDare the environment variables you configured in Step 1 for your private Git repository. Replacecodeup.aliyun.comwith your Git repository's domain, such asgithub.com.