插件 org.apache.maven.plugins:maven-clean-plugin:3.1.0 或其依赖项之一无法解析:

时间:2021-04-26 12:08:16

标签: maven jenkins artifactory

在尝试构建我的 maven 应用程序并在 jfrog 上部署工件时,它显示一个错误,即无法找到更具体的工件版本,错误日志如下所示。

[main] ERROR org.apache.maven.cli.MavenCli - Plugin org.apache.maven.plugins:maven-clean-plugin:3.1.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:3.1.0: Could not find artifact org.apache.maven.plugins:maven-plugins:pom:31 in artifactory-release (http://localhost:8081/artifactory/libs-release) -> [Help 1]

我的詹金斯管道看起来像这样

node {

def server
def buildInfo
def rtMaven
def mvnHome = tool 'Maven3'

stage ("checkout")  {
   git 'https://github.com/methelegend-sys/fisrt_jenkins'
}

  stage ('Artifactory configuration') {
    server = Artifactory.server('artifactory-server');
    rtMaven = Artifactory.newMavenBuild()
    rtMaven.tool = 'Maven3'
    rtMaven.deployer releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local', server: server
    rtMaven.resolver releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot', server: server
    //rtMaven.deployer.deployArtifacts = false // Disable artifacts deployment during Maven run

    //buildInfo = Artifactory.newBuildInfo()
    //rtMaven.tool = 'Maven3' // Tool name from Jenkins configuration
    //rtMaven.deployer releaseRepo:'example-repo-local', snapshotRepo:'example-repo-local', server: server
    //rtMaven.resolver releaseRepo:'example-repo-local', snapshotRepo:'example-repo-local', server: server
    buildInfo = Artifactory.newBuildInfo()
  }
  
   stage ('Build') {
       //bat 'mvn clean install'
        rtMaven.run -X pom: 'pom.xml', goals: 'clean install', buildInfo: buildInfo
    }
   
    stage ('Upload Artifacts') {
        rtMaven.deployer.deployArtifacts buildInfo
       server.publishBuildInfo buildInfo
    }
}   

我的 settings.xml 文件看起来像这样

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>
  
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>

  <servers>
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
  </mirrors>
<profiles>
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  </settings>

我不明白为什么构建会在本地存储库而不是远程存储库中查找插件。

当我尝试在不编写 jenkins 文件的情况下进行构建时,它也会成功构建,但如果是 jenkins 文件,则不会。

0 个答案:

没有答案