例如,AWS CodeArtifact 使用有效期为 12 小时的令牌进行身份验证。带有 CodeArtifact 的 maven 的典型设置是:
<servers>
<server>
<id>my-domain--my-repo</id>
<username>aws</username>
<password>${env.CODEARTIFACT_AUTH_TOKEN}</password>
</server>
</servers>
Run Code Online (Sandbox Code Playgroud)
在 settings.xml 中并执行
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain my-domain --domain-owner 123456789012 --query authorizationToken --output text)
Run Code Online (Sandbox Code Playgroud)
在调用 mvn 之前每 12 小时在终端中执行一次。
我以为我可以:
<servers>
<server>
<id>swifttech--main</id>
<username>aws</username>
<password>${codeartifact.auth.token}</password>
</server>
</servers>
Run Code Online (Sandbox Code Playgroud)
在 settings.xml 中,然后有一个
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<providerSelection>2.0</providerSelection>
<properties>
<script>aws codeartifact get-authorization-token --domain my-domain --domain-owner 123456789012 --query authorizationToken --output text</script>
</properties>
<source>
def command = project.properties.script
def process = …Run Code Online (Sandbox Code Playgroud)