JFrog Artifactory的Jenkins管道无法发布BuildInfo

时间:2017-05-09 05:17:57

标签: jenkins jenkins-pipeline artifactory

我在Jenkinsfile中写了groovy如下:

env.MVN_Goals = MVN_Goals
node {
 // Get Artifactory server instance, defined in the Artifactory Plugin administration page.
def server = Artifactory.newServer url: 'http://localhost:8085/artifactory', username: 'admin', password: 'password'
 // Create an Artifactory Maven instance.
 def rtMaven = Artifactory.newMavenBuild()

 stage ('Clone sources'){
     git url: 'D:/Sample GIT_Maven Repo'
 }

 stage 'Artifactory configuration'
    rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
    rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
    def buildInfo = Artifactory.newBuildInfo()


 stage('Maven_Build'){

 if (isUnix()) {
    sh "D:/apache-maven-3.3.9/bin/mvn -B -Dmaven ${MVN_Goals}"
 }

 else{
    bat "D:/apache-maven-3.3.9/bin/mvn -B -Dmaven ${MVN_Goals}"
 }

 step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
}
stage ('Publish build info'){
     server.publishBuildInfo buildInfo
 }
}

我尝试通过为Jenkins添加Artifactory插件来配置Jenkins中的Artifactory。当我尝试测试连接时,我收到错误There is either an incompatible or no instance of Artifactory at the provided URL。当我试图在Jenkins建立我的工作时发生同样的错误。有办法解决吗?

Artifactory插件版本 - 2.9.1

Artifactory Version - 4.15.0

1 个答案:

答案 0 :(得分:2)

def buildInfo = Artifactory.newBuildInfo()属于特定阶段。

将其修改为

env.MVN_Goals = MVN_Goals

node {

// Get Artifactory server instance,
// defined in the Artifactory Plugin administration page.

def server = Artifactory.newServer url: 'http://localhost:8085/artifactory', username: 'admin', password: 'password'

// Create an Artifactory Maven instance.

def rtMaven = Artifactory.newMavenBuild()

def buildInfo = Artifactory.newBuildInfo()

stage ('Clone sources'){

    git url: 'D:/Sample GIT_Maven Repo'
}