11version : 0.2
2- # this buildspec assumes the ubuntu 16.04:x64 image
2+ # Assumes are running using the Ubuntu Codebuild standard image
33# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
44# into it once all platforms are built and artifacted
55phases :
99 - sudo apt-get update -y
1010 - sudo apt-get install openjdk-8-jdk-headless maven -y -f
1111 - sudo apt-get install jq -y
12- # need latest awscli for secretsmanager
13- - sudo pip3 install awscli --upgrade
12+ - echo "\nBuild version data:"
13+ - echo "\nJava Version:"; java -version
14+ - echo "\nMaven Version:"; mvn --version
15+ - echo "\n"
1416
1517 pre_build :
1618 commands :
@@ -22,35 +24,37 @@ phases:
2224 - sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' aws-iot-device-sdk-java/pom.xml
2325 - sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' aws-iot-device-sdk-java-samples/pom.xml
2426 - sed -i 's/0.0.1-dev/'"$PKG_VERSION"'/g' aws-iot-device-sdk-java/src/main/java/com/amazonaws/services/iot/client/mqtt/AwsIotMqttConnection.java
25- # Get java v1 gpg files
26- - aws s3 cp --recursive s3://code-sharing-aws-crt/gpg-java-v1/ maven-gpg
27- # manully copy the maven-gpg in subfolder, since codeBuild does not set localRepository correctly
28- - cp -r maven-gpg aws-iot-device-sdk-java/maven-gpg
29- - cp -r maven-gpg aws-iot-device-sdk-java-samples/maven-gpg
27+
3028 # install settings.xml to ~/.m2/settings.xml
3129 - mkdir -p $HOME/.m2
32- - aws s3 cp s3://code-sharing-aws-crt/iot-sdk-java-v1.settings.central.xml $HOME/.m2/settings.xml
30+ - aws s3 cp s3://code-sharing-aws-crt/aws-iot-device-sdk.settings.token.xml $HOME/.m2/settings.xml
31+
3332 - aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token/V1 > sonatype_secret
3433 - jq fromjson sonatype_secret > sonatype_json
3534 - export ST_PASSWORD=$(jq -r '.password' sonatype_json)
3635 - export ESCAPED_PASSWORD=$(printf '%s\n' "$ST_PASSWORD" | sed 's:[\\/&]:\\&:g')
3736 - export ST_USERNAME=$(jq -r '.username' sonatype_json)
37+
3838 - aws --query "SecretString" secretsmanager get-secret-value --secret-id gpg/IoT/JAVA/V1 > gpg_secret
3939 - jq fromjson gpg_secret > gpg_json
40- - export GPG_PRINCIPAL=$(jq -r '.username' gpg_json)
4140 - export GPG_CREDENTIAL=$(jq -r '.password' gpg_json)
42- # Use the password from secret manager to update the settings
43- - sed -i 's/sonatype_Principal/'"$ST_USERNAME"'/g' $HOME/.m2/settings.xml
44- - sed -i 's/sonatype_Credential/'"$ESCAPED_PASSWORD"'/g' $HOME/.m2/settings.xml
45- - sed -i 's/gpg_Principal/'"$GPG_PRINCIPAL"'/g' $HOME/.m2/settings.xml
46- - sed -i 's/gpg_Credential/'"$GPG_CREDENTIAL"'/g' $HOME/.m2/settings.xml
4741
42+ # Use the username and password from secret manager to update the settings
43+ - sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
44+ - sed -i 's|token-password|'"$ESCAPED_PASSWORD"'|g' $HOME/.m2/settings.xml
45+
46+ # for https://github.com/keybase/keybase-issues/issues/2798
47+ - export GPG_TTY=$(tty)
48+
49+ - aws s3 cp s3://code-sharing-aws-crt/aws-iot-java-sdk.asc .
50+ - gpg --batch --import aws-iot-java-sdk.asc
51+ - export MAVEN_GPG_PASSPHRASE=$GPG_CREDENTIAL
4852
4953 build :
5054 commands :
5155 - cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java
5256 - mvn -B versions:set -DnewVersion=${PKG_VERSION}
53- - mvn clean deploy -P publishing -Dmaven.test.skip=true
57+ - mvn -B deploy -Dmaven.test.skip=true
5458
5559cache :
5660 paths :
0 commit comments