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.
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' :
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 ...
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
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
# 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
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
TiToch