Partage
  • Partager sur Facebook
  • Partager sur Twitter

Problème de compilation avec Maven dans cours OC

Cours CI/CD DevOps de Laurent Grangeau

2 mars 2020 à 20:59:09

Bonjour :)

Je viens de terminer la première partie du cours Mettez en place l'intégration et la livraison continues avec la démarche DevOps mais lors du premier quiz, je dois mettre en place une pipeline CI/CD. Afin de réussir le quiz, je doit trouver un message dans les logs, sauf que j'ai l'impression qu'il y a un problème de compilation avec Maven, et moi qui ait l'habitude d'utiliser Gradle je me retrouve un peu perdu. Je n'ai pourtant pas l'impression que le problème vient de moi puisque je n'ai touché à aucun fichier de code ou Maven. 

Merci d'avance pour votre aide, Baragouin.

  • Partager sur Facebook
  • Partager sur Twitter
13 juillet 2020 à 20:26:13

Bonjour Florence,

Je suis aussi au même point dans le cours CI/CD, j'ai aussi un problème similaire au tien et je suis aussi bloqué.

As-tu trouvé une réponse à ton problème ?

  • Partager sur Facebook
  • Partager sur Twitter
10 mars 2021 à 1:04:25

J'ai un le même problème...

J'ai intégré les dépdences junit et mockito dans le fichier pom.xml

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.6.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>2.23.4</version>
            <scope>test</scope>
        </dependency>

ps: intégrer les balises à l'intérieur de la section <dependencies></dependencies>

  • Partager sur Facebook
  • Partager sur Twitter
6 avril 2021 à 14:59:23

Bonjour,

J'ai le même souci et la solution proposé par kokouNovinyo ne fonctionne pas ...

kokouNovinyo a écrit:

J'ai un le même problème...

J'ai intégré les dépdences junit et mockito dans le fichier pom.xml

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.6.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>2.23.4</version>
            <scope>test</scope>
        </dependency>

ps: intégrer les balises à l'intérieur de la section <dependencies></dependencies>



  • Partager sur Facebook
  • Partager sur Twitter
31 août 2021 à 14:02:08

Bonjour,

J'ai eu le même problème.

Je l'ai résolu en faisant un merge de la partie du pom.xml du repository spring-petclinic et celui fourni dans le cours.

En gros il faut garder seulement la 1ère partie du pom.xml (<build .../> et <licence .../>) du github 

Et ajouter la partie du pom.xml du quizz OpenClassRoom à partir de <repositories.

Ca devrait permettre de résoudre le pb de compilation "cannot find symbol ... proxyBeanMethods()"

Ensuite on tombe sur une erreur de checkstyle lié au fichier ci-settings.xml et à tous les fichiers .pom sous .m2

J'ai modifié le contenu de <EXCLUDES> du "nohttp-checkstyle-validation" pour les exclure.

Donc remplacer : 

<excludes>**/.git/**/*,**/.idea/**/*,**/target/**/,**/.flattened-pom.xml,**/*.class</excludes>

par :

<excludes>**/.git/**/*,**/.idea/**/*,**/target/**/,**/.flattened-pom.xml,**/*.class,*settings.xml,**/.m2/**/*</excludes>



J'ai ENFIN obtenu un "Build Success" sur Gitlab !

Pour la livraison + déploiement :

Pour obtenir la phrase mystère (en début de log), il faut que le stage livraison+déploiement de GitLab soit 'deploy' et non pas 'package' comme dans le cours.

Chapitre "Codifier votre Infrastructure" (après le quizz)

Avant de modifier les versions dans les fichiers 'pom.xml' il faut avant tout indiquer dans le 'pom.xml' principal  (à la racine) la version du projet grâce à la variable 'project.version' :

<imageName>${env.CI_REGISTRY_IMAGE}/${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>


Sinon sans cette modification tous vos containers auront le tag 'latest" et seront remplacés à chaque livraison.

-
Edité par Christophe Le Ven 1 septembre 2021 à 16:26:45

  • Partager sur Facebook
  • Partager sur Twitter

TiToch

13 novembre 2021 à 0:56:41

Bonjour,

Pour ma part je rencontre un soucis sur le stage "package" du chapitre 4 avant le quizz.

Voici le message d'erreur
[WARNING] Failed to push springcommunity/spring-petclinic-api-gateway,
[INFO] Pushing springcommunity/spring-petclinic-api-gateway
The push refers to repository [docker.io/springcommunity/spring-petclinic-api-gateway]
600063 [INFO] ------------------------------------------------------------------------
600077 [INFO] Reactor Summary:
600080 [INFO]
600080 [INFO] spring-petclinic-microservices 2.5.1 ............... SUCCESS [ 2.093 s]
600083 [INFO] spring-petclinic-admin-server ...................... FAILURE [02:03 min]
600084 [INFO] spring-petclinic-customers-service ................. FAILURE [01:24 min]
600085 [INFO] spring-petclinic-vets-service ...................... FAILURE [01:17 min]
600086 [INFO] spring-petclinic-visits-service .................... FAILURE [01:16 min]
600087 [INFO] spring-petclinic-config-server ..................... FAILURE [01:06 min]
600087 [INFO] spring-petclinic-discovery-server .................. FAILURE [01:09 min]
600088 [INFO] spring-petclinic-api-gateway 2.5.1 ................. FAILURE [01:35 min]
600091 [INFO] ------------------------------------------------------------------------
600091 [INFO] BUILD FAILURE
600091 [INFO] ------------------------------------------------------------------------
600092 [INFO] Total time: 09:58 min
600094 [INFO] Finished at: 2021-11-12T23:13:32Z
600094 [INFO] ------------------------------------------------------------------------
600096 [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.0:build (default) on project spring-petclinic-admin-server: Exception caught: denied: requested access to the resource is denied -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:1.2.0:build (default) on project spring-petclinic-admin-server: Exception caught
On dirait qu'il y a un probleme d'authentification.
Cela dit, comme lors du clone on récupère la dernière version du microservice de petClinic, je pense que la version a évolué depuis et peut-être qu'une des configuration  n'est plus adaptée ?
Je pensais au .gitlab-ci.yml ou au dockerfile ou au pom.xml ?

----

Et pour le quizz ca claque dès le début :

Running with gitlab-runner 14.4.0-rc1 (bc99a056)
on docker-auto-scale 0277ea0f
Resolving secrets 00:00
Preparing the "docker+machine" executor 00:14
Using Docker executor with image laurentgrangeau/oc-devops:latest ...
Pulling docker image laurentgrangeau/oc-devops:latest ...
Using docker image sha256:249a6fe2790aedb66769b56c5b81d0c0963aeee3a450191bfd52d140d988b908 for laurentgrangeau/oc-devops:latest with digest laurentgrangeau/oc-devops@sha256:7705794a926904f3918848c85b11f783b6608f7dedf326ec30e56f4c752f8474 ...
Preparing environment 00:03
Running on runner-0277ea0f-project-31280828-concurrent-0 via runner-0277ea0f-srm-1636760718-2b8e7df5...
Getting source from Git repository 00:01
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/jerome_vinconneau/spring-petclinic/.git/
Created fresh repository.
Checking out 805c3d7f as main...
Skipping Git submodules setup
Restoring cache 00:01
Executing "step_script" stage of the job script 00:01
Using docker image sha256:249a6fe2790aedb66769b56c5b81d0c0963aeee3a450191bfd52d140d988b908 for laurentgrangeau/oc-devops:latest with digest laurentgrangeau/oc-devops@sha256:7705794a926904f3918848c85b11f783b6608f7dedf326ec30e56f4c752f8474 ...
/bin/sh: eval: line 117: ./mvnw: Permission denied
$ ./mvnw compile -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 126

-
Edité par JérômeVinçonneau 13 novembre 2021 à 0:59:01

  • Partager sur Facebook
  • Partager sur Twitter
5 avril 2022 à 16:19:39

Hello,

J'ai une erreur NullPointerException à l'étape du Build mais j'arrive pas à capter ce qui merde. Si jamais quelqu'un à une idée je suis preneur :) En attendant je vais continuer de chercher :)

41646 [INFO] ------------------------------------------------------------------------
41646 [INFO] BUILD FAILURE
41647 [INFO] ------------------------------------------------------------------------
41649 [INFO] Total time:  39.669 s
41653 [INFO] Finished at: 2022-04-05T14:08:03Z
41653 [INFO] ------------------------------------------------------------------------
41656 [ERROR] Failed to execute goal ro.isdc.wro4j:wro4j-maven-plugin:1.8.0:run (default) on project spring-petclinic: Exception in onAfterExecute: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal ro.isdc.wro4j:wro4j-maven-plugin:1.8.0:run (default) on project spring-petclinic: Exception in onAfterExecute
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
Caused by: org.apache.maven.plugin.MojoExecutionException: Exception in onAfterExecute
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.execute (AbstractWro4jMojo.java:184)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
Caused by: java.lang.NullPointerException
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.onAfterExecute (AbstractWro4jMojo.java:436)
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.execute (AbstractWro4jMojo.java:182)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
41721 [ERROR] 
41721 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
41721 [ERROR] 
41721 [ERROR] For more information about the errors and possible solutions, please read the following articles:
41721 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 1



  • Partager sur Facebook
  • Partager sur Twitter
3 mai 2022 à 2:08:20

Hello, to fix the error in stage "package" to build the docker image,

1) Update your main pom.xml in the project root folde: Replace  springcommunity by ${env.CI_REGISTRY_IMAGE} in docker.image.prefix

<docker.image.prefix>${env.CI_REGISTRY_IMAGE}</docker.image.prefix>

2) Update the block of "package" stage

  • change services docker:stable-dind by docker:18.09.7-dind 
  • variables: DOCKER_HOST: tcp://docker:2375 
  • script:  - apk add --no-cache docker openssh-client openssl-dev before docker-login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  • package-job:
      stage: package
      services:
        - docker:18.09.7-dind
      variables:
    #    DOCKER_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
        DOCKER_HOST: tcp://docker:2375
    #    DOCKER_DRIVER: overlay2
    #    DOCKER_TLS_CERTDIR: ""
      script:
        - apk add --no-cache docker openssh-client openssl-dev
    #    - apk add --no-cache docker openssh-client py3-pip python3-dev libffi-dev openssl-dev gcc libc-dev make
        - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
        - ./mvnw $MAVEN_OPTS $MAVEN_CLI_OPTS install -U -PbuildDocker -DskipTests=true -DpushImage
      image: openjdk:8-alpine

So below my complete pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.3</version>
    </parent>

    <groupId>org.springframework.samples</groupId>
    <artifactId>spring-petclinic-microservices</artifactId>
    <version>2.6.3</version>
    <name>${project.artifactId}</name>
    <packaging>pom</packaging>

    <modules>
        <module>spring-petclinic-admin-server</module>
        <module>spring-petclinic-customers-service</module>
        <module>spring-petclinic-vets-service</module>
        <module>spring-petclinic-visits-service</module>
        <module>spring-petclinic-config-server</module>
        <module>spring-petclinic-discovery-server</module>
        <module>spring-petclinic-api-gateway</module>
    </modules>

    <properties>
        <java.version>1.8</java.version>
        <assertj.version>3.17.1</assertj.version>

        <spring-boot.version>2.6.0</spring-boot.version>
        <spring-cloud.version>2021.0.1</spring-cloud.version>
        <chaos-monkey-spring-boot.version>2.3.10</chaos-monkey-spring-boot.version>

<!--        <docker.image.prefix>springcommunity</docker.image.prefix>-->
        <docker.image.prefix>${env.CI_REGISTRY_IMAGE}</docker.image.prefix>
        <docker.image.exposed.port>9090</docker.image.exposed.port>
        <docker.image.dockerfile.dir>${basedir}</docker.image.dockerfile.dir>
        <docker.image.dockerize.version>v0.6.1</docker.image.dockerize.version>
        <docker.plugin.version>1.2.0</docker.plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>chaos-monkey-spring-boot</artifactId>
                <version>${chaos-monkey-spring-boot.version}</version>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>${assertj.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <profiles>
        <profile>
            <id>springboot</id>
            <activation>
                <file>
                    <!-- Just a way to identify a Spring Boot application -->
                    <exists>src/main/resources/application.yml</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <!-- Spring Boot Actuator displays build-related information if a META-INF/build-info.properties file is present -->
                                <goals>
                                    <goal>build-info</goal>
                                </goals>
                                <configuration>
                                    <additionalProperties>
                                        <encoding.source>${project.build.sourceEncoding}</encoding.source>
                                        <encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
                                        <java.source>${maven.compiler.source}</java.source>
                                        <java.target>${maven.compiler.target}</java.target>
                                    </additionalProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Spring Boot Actuator displays build-related information if a META-INF/build-info.properties file is present -->
                    <plugin>
                        <groupId>pl.project13.maven</groupId>
                        <artifactId>git-commit-id-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>revision</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <verbose>true</verbose>
                            <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
                            <generateGitPropertiesFile>true</generateGitPropertiesFile>
                            <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
                            <failOnNoGitDirectory>false</failOnNoGitDirectory>
                            <failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>buildDocker</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>com.spotify</groupId>
                            <artifactId>docker-maven-plugin</artifactId>
                            <version>${docker.plugin.version}</version>
                            <executions>
                                <execution>
                                    <phase>install</phase>
                                    <goals>
                                        <goal>build</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                                <dockerDirectory>${docker.image.dockerfile.dir}</dockerDirectory>
                                <serverId>docker-hub</serverId>
                                <registryUrl>https://index.docker.io/v1/</registryUrl>
                                <resources>
                                    <resource>
                                        <targetPath>/</targetPath>
                                        <directory>${project.build.directory}</directory>
                                        <include>${project.build.finalName}.jar</include>
                                    </resource>
                                </resources>
                                <buildArgs>
                                    <ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
                                    <EXPOSED_PORT>${docker.image.exposed.port}</EXPOSED_PORT>
                                    <DOCKERIZE_VERSION>${docker.image.dockerize.version}</DOCKERIZE_VERSION>
                                </buildArgs>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>

</project>

And the complete gitlab-ci.yml

# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml

# This is a sample GitLab CI/CD configuration file that should run without any modifications.
# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
# it uses echo commands to simulate the pipeline execution.
#
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages


#image: maven:3.6-jdk-8


stages:          # List of stages for jobs, and their order of execution
  - build
  - test
  - quality
  - package

variables:
  # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
  # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
  MAVEN_OPTS: >-
    -Dhttps.protocols=TLSv1.2
    -Dmaven.repo.local=.m2/repository
    -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
    -Dorg.slf4j.simpleLogger.showDateTime=true
    -Djava.awt.headless=true
  # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
  # when running from the command line.
  # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
  MAVEN_CLI_OPTS: >-
    --batch-mode
    --errors
    --fail-at-end
    --show-version
    -DinstallAtEnd=true
    -DdeployAtEnd=true


build-job:       # This job runs in the build stage, which runs first.
  stage: build
  image: maven:3.8-openjdk-11
  # Cache downloaded dependencies and plugins between builds.
  # The key here separates one cache per branch/tag ($CI_COMMIT_REF_SLUG)
  cache:
    key: "maven-$CI_COMMIT_REF_SLUG"
    paths:
      - .m2/repository
  script:
    - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS clean package -DskipTests=true
  artifacts:
    name: "Maven artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
    paths:
      - "**/target"


unit-test-job:   # This job runs in the test stage.
  stage: test    # It only starts when the job in the build stage completes successfully.
  image: maven:3.8-openjdk-11
  # Cache downloaded dependencies and plugins between builds.
  # The key here separates one cache per branch/tag ($CI_COMMIT_REF_SLUG)
  cache:
    key: "maven-$CI_COMMIT_REF_SLUG"
    paths:
      - .m2/repository
  script:
    # the 'verify' goal is definitely the most appropriate here
    - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS test
  artifacts:
    name: "Maven artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
    paths:
      - "**/target"
    reports:
      # declare the JUnit reports (recursive pattern for multi-module projects)
      junit:
        - "**/target/*-reports/TEST-*.xml"


quality-job:
  stage: quality
  image: docker:stable
  allow_failure: true
  services:
    - docker:stable-dind
  script:
    - mkdir codequality-results
    - docker run
      --env CODECLIMATE_CODE="$PWD"
      --volume "$PWD":/code
      --volume /var/run/docker.sock:/var/run/docker.sock
      --volume /tmp/cc:/tmp/cc
      codeclimate/codeclimate analyze -f html > ./codequality-results/index.html
  artifacts:
    paths:
      - codequality-results/


package-job:
  stage: package
  services:
    - docker:18.09.7-dind
  variables:
#    DOCKER_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    DOCKER_HOST: tcp://docker:2375
#    DOCKER_DRIVER: overlay2
#    DOCKER_TLS_CERTDIR: ""
  script:
    - apk add --no-cache docker openssh-client openssl-dev
#    - apk add --no-cache docker openssh-client py3-pip python3-dev libffi-dev openssl-dev gcc libc-dev make
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - ./mvnw $MAVEN_OPTS $MAVEN_CLI_OPTS install -U -PbuildDocker -DskipTests=true -DpushImage
  image: openjdk:8-alpine

-
Edité par DiffouoJospin 3 mai 2022 à 11:34:29

  • Partager sur Facebook
  • Partager sur Twitter
26 février 2023 à 19:06:43

Bonjour,

Je suis aussi en train de faire le cours. De mon coté j'ai cette erreur, connaissant pas JAVA c'est dur ;-)

J'ai eu dans une premier temps ces erreurs par milier mais corrigées par les indications au dessus :

69328 [ERROR] .m2/repository/org/sonatype/oss/oss-parent/9/oss-parent-9.pom:[7,65] (extension) NoHttp: http:// URLs are not allowed but got 'http://www.apache.org/licenses/LICENSE-2.0'. Use https:// instead.

Puis j'ai eu :

67403 [WARNING] Error injecting: pl.project13.maven.git.GitCommitIdMojo
51java.lang.TypeNotPresentException: Type pl.project13.maven.git.GitCommitIdMojo not present
52    at org.eclipse.sisu.space.URLClassSpace.loadClass (URLClassSpace.java:147)
53    at org.eclipse.sisu.space.NamedClass.load (NamedClass.java:46)
54    at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
55    at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
56    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:57)
57    at com.google.inject.internal.ProviderInternalFactory$1.call (ProviderInternalFactory.java:66)
58    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:112)
59    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:127)
....

et plus tard :

67533 [ERROR] Failed to execute goal io.github.git-commit-id:git-commit-id-maven-plugin:5.0.0:revision (default) on project spring-petclinic: Execution default of goal io.github.git-commit-id:git-commit-id-maven-plugin:5.0.0:revision failed: Unable to load the mojo 'revision' in the plugin 'io.github.git-commit-id:git-commit-id-maven-plugin:5.0.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: pl/project13/maven/git/GitCommitIdMojo has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0



C'est étonnant de baser un cours sur un projet public qui évolue tout le temps :euh:

  • Partager sur Facebook
  • Partager sur Twitter