You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I have a pipeline for a Maven project, which contains 2 modules in it. In one of the modules, there is a dependency for a remote project, which can be pulled as a code artifact. The problem is that when i generate a token for AWS, to authenticate the for the download from the remote repository, the module which needs to pull the code artifact doesn't get authorization to download it. I get 401 unauthorized when whe pom.xml file tries to pull the dependency
pipelines:
default:
- step:
name: Build and Test
script:
- yum install sudo -y
- yum install zip unzip -y
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.0.30.zip" -o "awscliv2.zip"
- unzip awscliv2.zip
- sudo ./aws/install
- aws configure set aws_access_key_id $ACCESS_KEY
- aws configure set aws_secret_access_key $SECRET_ACCESS_KEY
- aws configure set profile.$PROFILE_NAME.source_profile default
- aws configure set profile.$PROFILE_NAME.region $AWS_REGION
- aws configure set profile.$PROFILE_NAME.role_arn $PROFILE_ARN
- export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $DOMAIN_OWNER --query authorizationToken --output text --profile $PROFILE_NAME`
- echo $CODEARTIFACT_AUTH_TOKEN
- sed -i 's/${env.CODEARTIFACT_AUTH_TOKEN}/'"$CODEARTIFACT_AUTH_TOKEN"'/g' $MODULE_PATH/settings.xml
- cat $MODULE_PATH/settings.xml
- mvn clean deploy -s $MODULE_PATH/pom.xml -P snapshot
- mvn verify --file pom.xml
Currently I'm writing using the 'sed' command to write the password directly in settings.xml, because I wasn't sure if it was being exported properly, but it doesn't work either way. From the 'cat' command i can verify that the token is actually written in the settings.xml file. Note that the only environment variable im using in the original pipeline is the $CODEARTIFACT_AUTH_TOKEN. I'm just using variables for everything here to not show sensitive data.
Welcome to the community.
Just wanted to confirm if the settings.xml file is located under the location "/usr/share/maven/conf"?
This is because you'll need to override the default Maven settings.xml found in the Docker image.
To access a private Maven repository, you'll need to override the default Maven settings.xml found in the Docker image at /usr/share/maven/conf/settings.xml.
Alternatively, you can also override the file by using your own version of the settings.xml file using the command below:
mvn -s settings.xml
You can also check out this link for more information.
Let me know how it goes.
Regards,
Mark C
Hi @Mark C , since posting the question, I was able to resolve the problem. It was indeed missing the settings.xml file. After adding it to the project the issue was resolved.
Still, thank you for the reply!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.