1

pom.xml免责声明:由于保密限制,我无法在此处发布我的项目的完整文件。但是我提取了相关部分来说明我遇到的问题。我的组织最近购买了 Artifactory,我正在努力在 Gitlab 中集成一个自动化 CI/CD 构建管道,因此我一直在尝试遵循JFrog 网站上的官方教程

管道失败的命令是它实际调用 maven 的地方(通过 JFrog CLI):

./jfrog rt mvn "clean compile install package -DskipTests" configuration.yml --build-name=gitlabci-maven-artifactory --build-number=$CI_JOB_ID

显示的错误消息看起来像这样。它实际上只是在这一点之后挂起;JFrog CLI 没有返回退出代码,所以我最终不得不终止 Gitlab 管道。

$ ./jfrog rt mvn "clean compile install package -DskipTests" configuration.yml --build-name=gitlabci-maven-artifactory --build-number=$CI_JOB_ID
[Info] Running Mvn...
[Info] Downloading jfrog/jfrog-jars/org/jfrog/buildinfo/build-info-extractor-maven3/2.9.2/build-info-extractor-maven3-2.9.2-uber.jar
[Info] [1]: 206 Partial Content...
[Info] [0]: 206 Partial Content...
[Info] [2]: 206 Partial Content...
[Info] Done downloading.
[Info] Downloaded 1 artifact.
...
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Scanning for projects...
[main] INFO org.jfrog.build.extractor.maven.BuildInfoRecorder - Initializing Artifactory Build-Info Recording
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - 
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - -------------------< com.mydomain:myproject >-------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Building MyProject 1.0.0
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --------------------------------[ jar ]---------------------------------
[main] ERROR org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener - Failed while enforcing Artifactory artifact resolver
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
    role: org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseArtifactResolver
roleHint: 
    at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:267)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:243)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:237)
    at org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener.enforceArtifactoryResolver (ArtifactoryEclipseRepositoryListener.java:71)
    at org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener.contextualize (ArtifactoryEclipseRepositoryListener.java:258)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.contextualize (PlexusLifecycleManager.java:282)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate (PlexusLifecycleManager.java:203)
    at org.eclipse.sisu.bean.BeanScheduler.schedule (BeanScheduler.java:151)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.manage (PlexusLifecycleManager.java:147)
    at org.eclipse.sisu.plexus.PlexusBeanBinder.afterInjection (PlexusBeanBinder.java:72)
    at com.google.inject.internal.MembersInjectorImpl.notifyListeners (MembersInjectorImpl.java:119)
    at com.google.inject.internal.ConstructorInjector.provision (ConstructorInjector.java:115)
    at com.google.inject.internal.ConstructorInjector.access$000 (ConstructorInjector.java:32)
    at com.google.inject.internal.ConstructorInjector$1.call (ConstructorInjector.java:89)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:115)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:133)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:68)
    at com.google.inject.internal.ConstructorInjector.construct (ConstructorInjector.java:87)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get (ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call (InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext (InjectorImpl.java:1103)
    at com.google.inject.internal.InjectorImpl$2.get (InjectorImpl.java:1012)
    at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1051)
    at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:81)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:53)
    at com.google.inject.internal.ProviderInternalFactory$1.call (ProviderInternalFactory.java:65)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:115)
    at org.eclipse.sisu.bean.BeanScheduler$CycleActivator.onProvision (BeanScheduler.java:230)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:126)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:68)
    at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:63)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call (ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext (InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get (ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get (SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get (InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InjectorImpl$2$1.call (InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext (InjectorImpl.java:1092)
    at com.google.inject.internal.InjectorImpl$2.get (InjectorImpl.java:1012)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
    at org.eclipse.sisu.wire.EntrySetAdapter$ValueIterator.next (EntrySetAdapter.java:102)
    at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch (DefaultRepositoryEventDispatcher.java:97)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.artifactResolving (DefaultArtifactResolver.java:640)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:254)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:224)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:201)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:261)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:192)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor (DefaultRepositorySystem.java:253)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:103)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:181)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor (DefaultMavenPluginManager.java:286)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor (DefaultBuildPluginManager.java:244)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleMappingDelegate.calculateLifecycleMappings (DefaultLifecycleMappingDelegate.java:115)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateLifecycleMappings (DefaultLifecycleExecutionPlanCalculator.java:265)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateMojoExecutions (DefaultLifecycleExecutionPlanCalculator.java:216)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:126)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:144)
    at org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan (BuilderCommon.java:96)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:110)
    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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.util.NoSuchElementException
    at java.util.Collections$EmptyIterator.next (Collections.java:4189)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:263)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:243)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:237)
    at org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener.enforceArtifactoryResolver (ArtifactoryEclipseRepositoryListener.java:71)
    at org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener.contextualize (ArtifactoryEclipseRepositoryListener.java:258)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.contextualize (PlexusLifecycleManager.java:282)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate (PlexusLifecycleManager.java:203)
    at org.eclipse.sisu.bean.BeanScheduler.schedule (BeanScheduler.java:151)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.manage (PlexusLifecycleManager.java:147)
    at org.eclipse.sisu.plexus.PlexusBeanBinder.afterInjection (PlexusBeanBinder.java:72)
    at com.google.inject.internal.MembersInjectorImpl.notifyListeners (MembersInjectorImpl.java:119)
    at com.google.inject.internal.ConstructorInjector.provision (ConstructorInjector.java:115)
    at com.google.inject.internal.ConstructorInjector.access$000 (ConstructorInjector.java:32)
    at com.google.inject.internal.ConstructorInjector$1.call (ConstructorInjector.java:89)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:115)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:133)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:68)
    at com.google.inject.internal.ConstructorInjector.construct (ConstructorInjector.java:87)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get (ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call (InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext (InjectorImpl.java:1103)
    at com.google.inject.internal.InjectorImpl$2.get (InjectorImpl.java:1012)
    at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1051)
    at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:81)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:53)
    at com.google.inject.internal.ProviderInternalFactory$1.call (ProviderInternalFactory.java:65)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:115)
    at org.eclipse.sisu.bean.BeanScheduler$CycleActivator.onProvision (BeanScheduler.java:230)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:126)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:68)
    at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:63)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call (ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext (InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get (ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get (SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get (InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InjectorImpl$2$1.call (InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext (InjectorImpl.java:1092)
    at com.google.inject.internal.InjectorImpl$2.get (InjectorImpl.java:1012)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
    at org.eclipse.sisu.wire.EntrySetAdapter$ValueIterator.next (EntrySetAdapter.java:102)
    at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch (DefaultRepositoryEventDispatcher.java:97)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.artifactResolving (DefaultArtifactResolver.java:640)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:254)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:224)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:201)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:261)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:192)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor (DefaultRepositorySystem.java:253)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:103)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:181)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor (DefaultMavenPluginManager.java:286)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor (DefaultBuildPluginManager.java:244)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleMappingDelegate.calculateLifecycleMappings (DefaultLifecycleMappingDelegate.java:115)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateLifecycleMappings (DefaultLifecycleExecutionPlanCalculator.java:265)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateMojoExecutions (DefaultLifecycleExecutionPlanCalculator.java:216)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:126)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:144)
    at org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan (BuilderCommon.java:96)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:110)
    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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[main] WARNING org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher - Failed to dispatch repository event to org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener: null
Downloading from central: http://repo1.maven.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.0.1.RELEASE/spring-boot-maven-plugin-2.0.1.RELEASE.pom
Progress (1): 4.1/4.8 kB
Progress (1): 4.8 kB    

Downloaded from central: http://repo1.maven.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.0.1.RELEASE/spring-boot-maven-plugin-2.0.1.RELEASE.pom (4.8 kB at 226 kB/s)

在我的 POM 文件中,我将 Maven Central 存储库与 Artifactory 一起引用为libs-releaselibs-snapshot. 我在部分中使用libs-release-local和。似乎它正在下载所有依赖项OK;但是我不确定为什么它会挂在这一点上。libs-snapshot-local<distributionManagement>ArtifactoryEclipseArtifactResolver

我不确定如何进行。这似乎很明显是 JFrog CLI 的问题(或者可能是我调用它的方式),因为我可以在本地系统上运行常规 Maven 并使一切正常。但我不确定如何解决这个问题并让 CI/CD 正常工作。

4

1 回答 1

1

在使用 Jenkins 管道将工件部署到 Artifactory 时,我遇到了同样的问题。我能够通过使用 Artifactory maven 插件来解决这个问题。下面是一个例子

<plugin>
                    <groupId>org.jfrog.buildinfo</groupId>
                    <artifactId>artifactory-maven-plugin</artifactId>
                    <version>2.6.1</version>
                    <executions>
                        <execution>
                            <id>build-info</id>
                            <goals>
                                <goal>publish</goal>
                            </goals>
                            <configuration>
                                <artifactory>
                                    <includeEnvVars>true</includeEnvVars>
                                    <envVarsExcludePatterns>*password*,*secret*,*key*,*token*,*passphrase*</envVarsExcludePatterns>
                                    <timeoutSec>60</timeoutSec>
                                </artifactory>
                                <publisher>
                                    <contextUrl>http://domain.name:not_a_default_port/artifactory/</contextUrl>
                                    <username>${username}</username> <!-- provided as env var -->
                                    <password>${password}</password> <!-- provided as env var -->
                                    <excludePatterns>*-tests.jar</excludePatterns>
                                    <repoKey>libs-release-local</repoKey>
                                    <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
                                </publisher>
                                <buildInfo>
                                    <buildName>${project.build.finalName}</buildName>
                                    <buildNumber>${project.version}</buildNumber>
                                    <buildUrl>https://fontys.nl/uitschrijven</buildUrl>
                                </buildInfo>
                            </configuration>
                        </execution>

                    </executions>
                </plugin>

使用此插件时,我在 Jenkinsfile 中创建了以下步骤:

stage ('Deploy to Artifactory') {
    steps {
        withMaven(
            maven: 'MAVEN_VERSION_CONFIGURED_IN_JENKINS',
            mavenSettingsConfig: 'optional config file id'
        ) {
            sh 'mvn deploy -Dusername=aaa -Dpassword=bbb -Dbuildnumber=ccc'
        }
    }
}
于 2018-04-18T11:46:24.077 回答