Home > OS >  Error when trying to deploy to AZURE Failed to execute goal org.apache.maven.plugins:maven-surefire-
Error when trying to deploy to AZURE Failed to execute goal org.apache.maven.plugins:maven-surefire-

Time:05-27

Hi developers friends I need help please When I try to deploy from github to my Azure AppService the github console shows me the following error.

Hi developers friends I need help please When I try to deploy from github to my Azure AppService the github console shows me the following error.

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project FastFoodApp: There are test failures.

Please refer to /home/runner/work/Project-Name/target/surefire-reports for the individual test results. Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging.

I already tried adding mvn clean install -DskipTests in the .yml file. Also adding in the pom.xml file

<dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.5.2</version>
</dependency>

Also

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
            <testFailureIgnore>true</testFailureIgnore>
            </configuration>
</plugin>

Also I tried commenting out all code in src/test/java -> test.java

But in the end it always shows me the same error

this is the .yml file

name: Build and deploy JAR app to Azure Web App - fastfoodapi

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Java version
        uses: actions/setup-java@v1
        with:
          java-version: '11'

      - name: Build with Maven
        run: mvn clean install

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: java-app
          path: '${{ github.workspace }}/target/*.jar'

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: java-app

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'fastfoodapi'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_2896B985447E4F1D85D4FE3ECA3795AC }}
          package: '*.jar'

CodePudding user response:

Try the following steps to resolve the error:

  • Right Click on project > Run as Maven Test.
  • The missing plugin will be downloaded automatically.
  • Right Click on project > Update Maven project, after that the error should be gone.

References:

  1. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test" and "test(s) <[]> cannot be found"
  2. How to solve "failed to execute goal "maven-surefire-plugin:2.19.1" in maven
  3. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test
  4. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test
  • Related