I am using google cloud build to build my maven projects and I use JFrog Artifactory registry to store maven artifacts. In cloud build need these artifacts. I tried with several documentation pages (1, 2). But time to time it gives many errors.
Can I take proper latest updated guide to integrate cloud build and Artifactory? Proper authentication method need to use other than user name password. API key method can be used.
I set M2_HOME as MAVEN_HOME. Then that issue was fixed. But new error given as Unsupported major.minor version 52.0. This is common issue with java version mismatch.
Error message:
Step #1: [Info] Running Mvn...
Step #1: [Info] The build-info-extractor jar is not cached locally. Downloading it now...
Step #1: You can set the repository from which this jar is downloaded. Read more about it at https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-DownloadingtheMavenandGradleExtractorJARs
Step #1: [Info] Downloading build-info-extractor from https://oss.jfrog.org/artifactory/oss-release-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.26.1/build-info-extractor-maven3-2.26.1-uber.jar
Step #1: [main] WARN Sisu - Error injecting: org.jfrog.build.extractor.maven.DependencyResolutionSpy
Step #1: java.lang.TypeNotPresentException: Type org.jfrog.build.extractor.maven.DependencyResolutionSpy not present
Step #1: at org.eclipse.sisu.space.URLClassSpace.loadClass(URLClassSpace.java:115)
Step #1: at org.eclipse.sisu.space.NamedClass.load(NamedClass.java:46)
Step #1: at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
Step #1: at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
Step #1: at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:54)
Step #1: at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
Step #1: at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:113)
Step #1: at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:129)
Step #1: at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
Step #1: at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
Step #1: at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:46)
Step #1: at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
Step #1: at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
Step #1: at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
Step #1: at com.google.inject.Scopes$1$1.get(Scopes.java:59)
Step #1: at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
Step #1: at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1009)
Step #1: at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
Step #1: at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1005)
Step #1: at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
Step #1: at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
Step #1: at org.eclipse.sisu.wire.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:111)
Step #1: at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
Step #1: at java.util.ArrayList.(ArrayList.java:164)
Step #1: at org.apache.maven.eventspy.internal.EventSpyDispatcher.setEventSpies(EventSpyDispatcher.java:49)
Step #1: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Step #1: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Step #1: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Step #1: at java.lang.reflect.Method.invoke(Method.java:606)
Step #1: at org.eclipse.sisu.bean.BeanPropertySetter.set(BeanPropertySetter.java:76)
Step #1: at org.eclipse.sisu.plexus.ProvidedPropertyBinding.injectProperty(ProvidedPropertyBinding.java:48)
Step #1: at org.eclipse.sisu.bean.BeanInjector.injectMembers(BeanInjector.java:52)
Step #1: at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:140)
Step #1: at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:117)
Step #1: at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
Step #1: at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:92)
Step #1: at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:113)
Step #1: at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:176)
Step #1: at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:122)
Step #1: at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
Step #1: at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
Step #1: at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:269)
Step #1: at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
Step #1: at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
Step #1: at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
Step #1: at com.google.inject.Scopes$1$1.get(Scopes.java:59)
Step #1: at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
Step #1: at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1009)
Step #1: at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1059)
Step #1: at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1005)
Step #1: at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
Step #1: at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
Step #1: at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
Step #1: at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
Step #1: at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
Step #1: at org.apache.maven.cli.MavenCli.container(MavenCli.java:419)
Step #1: at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:210)
Step #1: at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
Step #1: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Step #1: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Step #1: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Step #1: at java.lang.reflect.Method.invoke(Method.java:606)
Step #1: at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
Step #1: at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
Step #1: at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
Step #1: at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Step #1: Caused by: java.lang.UnsupportedClassVersionError: org/jfrog/build/extractor/maven/DependencyResolutionSpy : Unsupported major.minor version 52.0
Step #1: at java.lang.ClassLoader.defineClass1(Native Method)
Step #1: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
Step #1: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
Step #1: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
Step #1: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
Step #1: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
Step #1: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
Step #1: at java.security.AccessController.doPrivileged(Native Method)
Step #1: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
Step #1: at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
Step #1: at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
Step #1: at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
Step #1: at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
Step #1: at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
Step #1: at org.eclipse.sisu.space.URLClassSpace.loadClass(URLClassSpace.java:107)
Step #1: ... 65 more
Step #1: [main] ERROR org.apache.maven.cli.MavenCli - Error executing Maven.
Step #1: [main] ERROR org.apache.maven.cli.MavenCli - com.google.inject.ProvisionException: Unable to provision, see the following errors:
Step #1:
Step #1: 1) Error injecting: public void org.apache.maven.eventspy.internal.EventSpyDispatcher.setEventSpies(java.util.List)
Step #1: at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
Step #1: while locating org.apache.maven.eventspy.internal.EventSpyDispatcher
Step #1:
Step #1: 1 error
Step #1: role: org.apache.maven.eventspy.internal.EventSpyDispatcher
Step #1: roleHint:
Step #1: [main] ERROR org.apache.maven.cli.MavenCli - Caused by: Unable to provision, see the following errors:
Step #1:
Step #1: 1) Error injecting: public void org.apache.maven.eventspy.internal.EventSpyDispatcher.setEventSpies(java.util.List)
Step #1: at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
Step #1: while locating org.apache.maven.eventspy.internal.EventSpyDispatcher
Step #1:
Step #1: 1 error
Step #1: [main] ERROR org.apache.maven.cli.MavenCli - Caused by: Unable to provision, see the following errors:
Step #1:
Step #1: 1) Error in custom provider, java.lang.TypeNotPresentException: Type org.jfrog.build.extractor.maven.DependencyResolutionSpy not present
Step #1: at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
Step #1: at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
Step #1: while locating org.apache.maven.eventspy.EventSpy
Step #1:
Step #1: 1 error
Step #1: [main] ERROR org.apache.maven.cli.MavenCli - Caused by: Type org.jfrog.build.extractor.maven.DependencyResolutionSpy not present
Step #1: [main] ERROR org.apache.maven.cli.MavenCli - Caused by: org/jfrog/build/extractor/maven/DependencyResolutionSpy : Unsupported major.minor version 52.0
Step #1: [Error] exit status 1
Is this error due to https://oss.jfrog.org/artifactory/oss-release-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.26.1/build-info-extractor-maven3-2.26.1-uber.jar or any other reason?
How I solve this issue?
I solved this issue using maven settings xml file. I followed below steps.
Create maven settings.xml in root directory.
<servers>
<server>
<id>repo</id>
<username>${server.username}</username>
<password>${server.password}</password>
</server>
</servers>
Create keyring and keys in google cloud.
gcloud kms keyrings create [KEYRING-NAME] --location=global
gcloud kms keys create [KEY-NAME] --location=global --keyring=[KEYRING-NAME] --purpose=encryption
Encrypt JFrog username and password using above keyring and key
USERNAME=aaa
echo $USERNAME | gcloud kms encrypt --plaintext-file=- --ciphertext-file=- --location=global --keyring=[KEYRING-NAME] --key=[KEY-NAME] | base64
Create cloud build file to build maven
steps:
- name: 'gcr.io/cloud-builders/mvn:3.5.0-jdk-8'
entrypoint: 'bash'
args: ['-c', 'mvn clean package -DskipTests=true -Dserver.username=$$USERNAME -Dserver.password=$$PASSWORD -s settings.xml -q']
secretEnv: ['USERNAME', 'PASSWORD']
secrets:
- kmsKeyName: projects/[PROJECT]/locations/global/keyRings/jfrog/cryptoKeys/jfrog
secretEnv:
USERNAME: [ENCRYPTED-USERNAME]
PASSWORD: [ENCRYPTED-PASSWORD]