I am using Maven 3.6.3 try try connect to a CodeArtifact repository.
Based on this AWS documentation. I do the following:
Set up the password:
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain my-domain --domain-owner XXXXXX --region us-east-1 --query authorizationToken --output text`
then
echo $CODEARTIFACT_AUTH_TOKEN
This outputs a token as expected. I also try hard-code the token in the settings.xml file, but I get the same error below.
.m2/settings.xml
<servers>
<server>
<id>my-domain-my-repository</id>
<username>aws</username>
<password>${env.CODEARTIFACT_AUTH_TOKEN}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>my-domain-my-repository</id>
<name>my-domain-my-repository</name>
<url>https://my-domain-XXXXXX.d.codeartifact.us-east-1.amazonaws.com/maven/my-repository/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profile>
<id>my-domain-my-repository</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>my-domain-my-repository</id>
<url>https://my-domain-XXXXXX.d.codeartifact.us-east-1.amazonaws.com/maven/my-repository/</url>
</repository>
</repositories>
</profile>
Then I execute this command to upload a file.
mvn deploy:deploy-file \
-DgroupId=com.travellinck.integration \
-DartifactId=travellinck-osgi-bom \
-Dversion=1.0 \
-Dfile=/Users/richardmarais/IdeaProjects/deleteme/travellinck-osgi-bom-1.0.pom \
-Dpackaging=pom \
-DrepositoryId=my-domain-my-repository \
-Durl=https://my-domain-XXXXXX.d.codeartifact.us-east-1.amazonaws.com/maven/my-repository/
Error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.travellinck.integration:travellinck-osgi-bom:pom:1.0 from/to my-domain-my-repository (https://my-domain-XXXXXX.d.codeartifact.us-east-1.amazonaws.com/maven/my-repository/): my-domain-XXXXXX.d.codeartifact.us-east-1.amazonaws.com:443 failed to respond
Question
Why can't maven connect to the repo?
If I change the password in the settings.xml to any random characters, it gets the same error.
<password>ABC</password>
More info
I do the equivalent using a curl
command, and this successfully uploads to the CodeArtifact repository.
curl --request PUT https://my-domain-XXXXXX.d.codeartifact.us-east-1.amazonaws.com/maven/my-repository/com/travellinck/integration/travellinck-osgi-bom/1.0/travellinck-osgi-bom-1.0.pom \
--user "aws:$CODEARTIFACT_AUTH_TOKEN" --header "Content-Type: application/octet-stream" \
--data-binary @/Users/richardmarais/.m2/repository/com/travellinck/integration/travellinck-osgi-bom/1.0/travellinck-osgi-bom-1.0.pom
Which shows that the CODEARTIFACT_AUTH_TOKEN
is working and can connect to the repo.