Reputation: 873
I have been searching a lot for getting a sample buildspec where integrates the codeartifacts with mvn.
here is my buildpsec is, following is my doubts.
buildspec file
version: 0.2
phases:
install:
runtime-versions:
java: openjdk8
commands:
- pip3 install awscli --upgrade --user
- export CODEARTIFACT_TOKEN=`aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT_ID --query authorizationToken --output text`
build:
commands:
- echo Build started on `date`
- mvn package
artifacts:
type: zip
files:
- '/target/launcher-0.0.1-SNAPSHOT.jar'
cache:
paths:
- '/root/.m2/**/*'.
Upvotes: 2
Views: 2455
Reputation: 2050
since we cannot create a setting.xml where aws tells us to mention the servers, mirrors, profile and token, how can we upload the dependencies to the artifact repository.
In fact, you can. You were on the right track.
mvn
will not execute until the build
phase, so in install
you can edit its settings, including settings.xml
. The easiest is to replace them altogether:
phases:
install:
commands:
- cp ./codebuild-maven-settings.xml /root/.m2/settings.xml
You can then use your CODEARTIFACT_TOKEN
environment variable in the custom settings.xml
file.
In order for this solution to work you need to put the codebuild-maven-settings.xml
file at the root of your repository. This might not be the most elegant and if you want to truely make this as smooth as possible, I recommend putting the file on S3 and downloading it first.
Upvotes: 7