diff --git a/Jenkinsfile b/Jenkinsfile index 1b5428f5..afc10592 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,8 +66,16 @@ options { disableConcurrentBuilds() } stage('Build') { steps { echo 'Building project...' - sh "./mvnw install source:jar-no-fork -Prelease,ossrh -U -s settings.xml" - } + withCredentials([file(credentialsId: 'gpg-private-key', variable: 'GPG_KEY')]) { + sh "gpg2 --no-tty --import $GPG_KEY || /bin/true" + withPullRequestBranch { + sh "./mvnw install source:jar-no-fork -Prelease -U -s settings.xml" + } + withMasterBranch { + sh "./mvnw deploy source:jar-no-fork -Prelease -U -s settings.xml" + } + } + } } stage('SonarQube') { diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..d82490ec --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.host.url=https://sonar.appdirect.tools +sonar.projectKey=service-integration-sdk +sonar.projectName=service-integration-sdk +sonar.sources=src/main +sonar.java.binaries=target/classes +sonar.java.libraries=target/*.jar diff --git a/src/script/addkeys.sh b/src/script/addkeys.sh index 9e177c21..3b29ac68 100755 --- a/src/script/addkeys.sh +++ b/src/script/addkeys.sh @@ -1,7 +1,11 @@ #!/bin/bash -sed '/<\/settings>/{ - r src/script/settings - a \ +sed '/<\/profiles>/{ + r src/script/profiles + a \ d -}' mavenSettings | sed -e "s/GPG_PASSPHRASE/$GPG_PASSPHRASE/" -e "s/OSSRH_USERNAME/$OSSRH_USERNAME/" -e "s/OSSRH_PASSWORD/$OSSRH_PASSWORD/" > settings.xml +}' mavenSettings |sed '/<\/servers>/{ + r src/script/servers + a \ + d +}' | sed -e "s/GPG_PASSPHRASE/$GPG_PASSPHRASE/" -e "s/OSSRH_USERNAME/$OSSRH_USERNAME/" -e "s/OSSRH_PASSWORD/$OSSRH_PASSWORD/" > settings.xml diff --git a/src/script/profiles b/src/script/profiles new file mode 100644 index 00000000..2be439f4 --- /dev/null +++ b/src/script/profiles @@ -0,0 +1,10 @@ + + ossrh + + true + + + gpg2 + GPG_PASSPHRASE + + \ No newline at end of file diff --git a/src/script/servers b/src/script/servers new file mode 100644 index 00000000..a9c8d0da --- /dev/null +++ b/src/script/servers @@ -0,0 +1,5 @@ + + ossrh + OSSRH_USERNAME + OSSRH_PASSWORD + \ No newline at end of file diff --git a/src/script/settings b/src/script/settings deleted file mode 100644 index c428551c..00000000 --- a/src/script/settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - ossrh - OSSRH_USERNAME - OSSRH_PASSWORD - - - - - ossrh - - true - - - gpg - GPG_PASSPHRASE - - - - \ No newline at end of file