Приложение, которое я пытаюсь собрать с помощью Jenkins, не может работать правильно, потому что плагины / зависимости отсутствуют. Я использую JFrog Artifactory в своем конвейере, и я верю, что именно это вызывает эту проблему. Всякий раз, когда я использую mvn clean install
, кажется, что загружаются все зависимости, но когда я использую Jenkins для построения проекта, выдается следующая ошибка:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\Maven-project
[Pipeline] {
[Pipeline] newArtifactoryServer
[Pipeline] newMavenBuild
[Pipeline] stage
[Pipeline] { (Clone)
[Pipeline] git
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://github.com/JFrog/project-examples.git # timeout=10
Fetching upstream changes from https://github.com/JFrog/project-examples.git
> git.exe --version # timeout=10
> git.exe fetch --tags --force --progress https://github.com/JFrog/project-examples.git +refs/heads/*:refs/remotes/origin/*
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 67bf31bad1fca27577ec0c880a90bd08c959ef8c (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f 67bf31bad1fca27577ec0c880a90bd08c959ef8c
> git.exe branch -a -v --no-abbrev # timeout=10
> git.exe branch -D master # timeout=10
> git.exe checkout -b master 67bf31bad1fca27577ec0c880a90bd08c959ef8c
Commit message: "Merge pull request #148 from aaron-tyler/patch-1"
> git.exe rev-list --no-walk 67bf31bad1fca27577ec0c880a90bd08c959ef8c # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Artifactory configuration)
[Pipeline] newBuildInfo
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Exec Maven)
[Pipeline] artifactoryMavenBuild
Jenkins Artifactory Plugin version: 3.0.0
Artifactory integration is enabled
[Maven-project] $ "C:\Program Files\Java\jdk-11.0.1\bin/java.exe" -classpath "C:\Program Files\apache-maven-3.6.0\boot\*" "-Dmaven.home=C:\Program Files\apache-maven-3.6.0" "-Dmaven.conf=C:\Program Files\apache-maven-3.6.0\conf" "-DbuildInfoConfig.propertiesFile=C:\Program Files (x86)\Jenkins\workspace\Maven-project@tmp\artifactory\buildInfo2318213825585143053.properties" -DbuildInfoConfig.artifactoryResolutionEnabled=true "-Dm3plugin.lib=C:\Program Files (x86)\Jenkins\workspace\Maven-project@tmp\artifactory\cache\artifactory-plugin\3.0.0" "-Dclassworlds.conf=C:\Program Files (x86)\Jenkins\workspace\Maven-project@tmp\artifactory\classworlds746621898485622615conf" "-Dmaven.multiModuleProjectDirectory=C:\Program Files (x86)\Jenkins\workspace\Maven-project" org.codehaus.plexus.classworlds.launcher.Launcher -f maven-example/pom.xml clean install
[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 - Reactor Build Order:
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Simple Multi Modules Build [pom]
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Multi 1 [jar]
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Multi 2 [jar]
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Multi 3 [war]
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------< org.jfrog.test:multi >------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Building Simple Multi Modules Build 3.7-SNAPSHOT [1/4]
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --------------------------------[ pom ]---------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Reactor Summary for Simple Multi Modules Build 3.7-SNAPSHOT:
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Simple Multi Modules Build ......................... FAILURE [ 0.040 s]
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Multi 1 ............................................ SKIPPED
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Multi 2 ............................................ SKIPPED
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Multi 3 ............................................ SKIPPED
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD FAILURE
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time: 0.161 s
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: 2019-01-16T00:26:37+01:00
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] ERROR org.apache.maven.cli.MavenCli - Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-plugins:pom:22 from/to artifactory-release (Artifactory/libs-release): Cannot access Artifactory/libs-release with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access Artifactory/libs-release using the registered transporter factories: WagonTransporterFactory: Unsupported transport protocol -> [Help 1]
[main] ERROR org.apache.maven.cli.MavenCli -
[main] ERROR org.apache.maven.cli.MavenCli - To see the full stack trace of the errors, re-run Maven with the -e switch.
[main] ERROR org.apache.maven.cli.MavenCli - Re-run Maven using the -X switch to enable full debug logging.
[main] ERROR org.apache.maven.cli.MavenCli -
[main] ERROR org.apache.maven.cli.MavenCli - For more information about the errors and possible solutions, please read the following articles:
[main] ERROR org.apache.maven.cli.MavenCli - [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.RuntimeException: Maven build failed
at org.jfrog.hudson.pipeline.common.executors.MavenExecutor.execute(MavenExecutor.java:72)
at org.jfrog.hudson.pipeline.scripted.steps.ArtifactoryMavenBuild$Execution.run(ArtifactoryMavenBuild.java:78)
at org.jfrog.hudson.pipeline.scripted.steps.ArtifactoryMavenBuild$Execution.run(ArtifactoryMavenBuild.java:53)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Finished: FAILURE
Используемый мной конвейер выглядит следующим образом:
node {
def server = Artifactory.newServer url: 'Artifactory'
def rtMaven = Artifactory.newMavenBuild()
stage ('Clone') {
git url: 'https://github.com/JFrog/project-examples.git'
}
stage ('Artifactory configuration') {
rtMaven.tool = 'Local Maven' // Tool name from Jenkins configuration
rtMaven.deployer releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local', server: server
rtMaven.resolver releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot', server: server
buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
}
stage ('Exec Maven') {
rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean install', buildInfo: buildInfo
}
stage ('Publish build info') {
server.publishBuildInfo buildInfo
}
}
POM файл:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>java-maven-junit-helloworld</artifactId>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- This configures the compiler to produce Java 8 class files. -->
<!-- The minimum JDK version installed is 8 of course, but newer JDK releases should work too. -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<junit.jupiter.version>5.4.0-M1</junit.jupiter.version>
<junit.platform.version>1.2.0</junit.platform.version>
<hamcrest.version>1.3</hamcrest.version>
<mockito.version>2.21.0</mockito.version>
<jacoco.plugin.version>0.8.1</jacoco.plugin.version>
</properties>
<dependencies>
<!-- Testing dependencies. -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Configures the compiler. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<!-- Unit tests are run by surefire. -->
<!-- Classes under src/test/java called *Test are included automatically. -->
<!-- Unit tests are run during the test phase. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<!-- Integration tests are run by failsafe. -->
<!-- Classes under src/test/java called *IT are included automatically. -->
<!-- Integration tests are run during the verify phase. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin> -->
<!-- Code coverage plugin. -->
<!-- This sets up code coverage for the unit tests, the integration tests, -->
<!-- and the combined coverage of both. -->
<!-- After running a `mvn clean install`, open `target/site/jacoco-both/index.html` in a browser. -->
<!-- <groupId>org.jacoco</groupId> -->
<!-- <artifactId>jacoco-maven-plugin</artifactId> -->
<!-- <version>${jacoco.plugin.version}</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>jacoco-prepare-agent</id> -->
<!-- <goals> -->
<!-- <goal>prepare-agent</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- <execution> -->
<!-- <id>jacoco-prepare-agent-integration</id> -->
<!-- <goals> -->
<!-- <goal>prepare-agent-integration</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- <execution> -->
<!-- <id>jacoco-report</id> -->
<!-- <goals> -->
<!-- <goal>report</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- <execution> -->
<!-- <id>jacoco-check</id> -->
<!-- <goals> -->
<!-- <goal>check</goal> -->
<!-- </goals> -->
<!-- <configuration> -->
<!-- <rules /> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- <execution> -->
<!-- Combine the code coverage statistics generated for the unit and the integration tests. -->
<!-- <id>jacoco-merge</id> -->
<!-- <goals> -->
<!-- <goal>merge</goal> -->
<!-- </goals> -->
<!-- <phase>verify</phase> -->
<!-- <configuration> -->
<!-- <fileSets> -->
<!-- <fileSet> -->
<!-- <directory>${project.build.directory}</directory> -->
<!-- <includes> -->
<!-- <include>*.exec</include> -->
<!-- </includes> -->
<!-- </fileSet> -->
<!-- </fileSets> -->
<!-- <destFile>${project.build.directory}/jacoco-both.exec</destFile> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- <execution> -->
<!-- <id>jacoco-integration</id> -->
<!-- <goals> -->
<!-- <goal>report-integration</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- <execution> -->
<!-- <id>jacoco-reportboth</id> -->
<!-- <goals> -->
<!-- <goal>report</goal> -->
<!-- </goals> -->
<!-- <configuration> -->
<!-- <dataFile>${project.build.directory}/jacoco-both.exec</dataFile> -->
<!-- <outputDirectory>${project.reporting.outputDirectory}/jacoco-both</outputDirectory> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
</plugins>
</build>
</project>