diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f668817031..0000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Build -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v1 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=oracle_weblogic-deploy-tooling diff --git a/Jenkinsfile b/Jenkinsfile index 9d9ca08767..8023607e83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,12 +13,7 @@ pipeline { jdk 'jdk8' } steps { - sh ''' - echo "PATH = ${PATH}" - echo "JAVA_HOME = ${JAVA_HOME}" - echo "M2_HOME = ${M2_HOME}" - mvn --version - ''' + sh 'env|sort' } } stage ('Build') { @@ -42,7 +37,7 @@ pipeline { } } steps { - sh 'mvn -Dunit-test-wlst-dir=${WLST_DIR} test' + sh 'mvn -B -Dunit-test-wlst-dir=${WLST_DIR} test' } post { always { @@ -67,7 +62,7 @@ pipeline { } } steps { - sh 'mvn -DskipITs=false -Dmw_home=${ORACLE_HOME} -Ddb.use.container.network=true verify' + sh 'mvn -B -DskipITs=false -Dmw_home=${ORACLE_HOME} -Ddb.use.container.network=true verify' } post { always { @@ -75,7 +70,26 @@ pipeline { } } } - stage ('Alias Test') { + stage ('Analyze') { + when { + anyOf { + changeRequest() + branch "main" + } + } + tools { + maven 'maven-3.6.0' + jdk 'jdk11' + } + steps { + withSonarQubeEnv('SonarCloud') { + withCredentials([string(credentialsId: 'encj_github_token', variable: 'GITHUB_TOKEN')]) { + runSonarScanner() + } + } + } + } + stage ('Alias Test') { // only run this stage when triggered by a cron timer and the commit does not have []skip-ci in the message // for example, only run integration tests during the timer triggered nightly build when { @@ -129,6 +143,24 @@ pipeline { ''' } } + } +} +void runSonarScanner() { + def changeUrl = env.CHANGE_URL.split("/") + def org = changeUrl[3] + def repo = changeUrl[4] + if (changeRequest()) { + sh "mvn -B sonar:sonar \ + -Dsonar.projectKey=${org}_${repo} \ + -Dsonar.pullrequest.provider=GitHub \ + -Dsonar.pullrequest.github.repository=${org}/${repo} \ + -Dsonar.pullrequest.key=${env.CHANGE_ID} \ + -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} \ + -Dsonar.pullrequest.base=${env.CHANGE_TARGET}" + } else { + sh "mvn -B sonar:sonar \ + -Dsonar.projectKey=${org}_${repo} \ + -Dsonar.branch.name=${env.BRANCH_NAME}" } } diff --git a/core/pom.xml b/core/pom.xml index 5ddc75ccc2..f54136cf62 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -88,6 +88,10 @@ + + org.jacoco + jacoco-maven-plugin + org.apache.maven.plugins maven-jar-plugin @@ -163,10 +167,6 @@ org.codehaus.mojo flatten-maven-plugin - - org.jacoco - jacoco-maven-plugin - diff --git a/pom.xml b/pom.xml index 8174a79be2..4b6c34a46e 100644 --- a/pom.xml +++ b/pom.xml @@ -51,8 +51,11 @@ https://sonarcloud.io src/main 7 + 2 .flattened-pom.xml,target/** - src/test/** + core/src/test/** + core/target/site/jacoco/jacoco.xml + ${env.WLST_DIR} true true @@ -152,10 +155,6 @@ org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5 - - - ${surefireArgLine} - io.rhpatrick.mojo @@ -183,25 +182,17 @@ 0.8.7 - pre-unit-test + prepare-agent prepare-agent - - ${sonar.jacoco.reportPath} - surefireArgLine - - post-unit-test - site + report + post-integration-test report - - ${project.reporting.outputDirectory}/jacoco-ut - ${sonar.jacoco.reportPath} -