2016-07-22 76 views
1

我想在python腳本中使用maven將工件上傳到Nexus。我看着它在這裏:https://gist.github.com/adamv/705292如何使用python上的Maven上傳到Nexus

和我做了以下的方法:

def local2(command, print_command=False): 
    from subprocess import Popen, PIPE 
    p = Popen(command, stdout=PIPE, stderr=PIPE) 
    if print_command: print " ".join(command) 
    output, errput = p.communicate() 
    return p.returncode, output, errput 

def uploadQAJavaToNexus(): 
    url = "example" 
    groupId = "example" 
    artifactId = "example" 
    repositoryId = "example" 
    # filePath = 
    version = "version" 

    status, stdout, stderr = local2([ 
            MAVEN_BINARY, 
            "deploy:deploy-file", 
            "-Durl=" +url, 
            "-DrepositoryId=" +repositoryId, 
            "-Dversion=" + version, 
            "-Dfile=" + "path" 
            "-DartifactId=" + artifactId, 
            "-Dpackaging=" + "jar", 
            "-DgroupId" + groupId, 
            ]) 
    return status, stdout, stderr 

但是我卻越來越不確定的變量MAVEN_BINARY。這是什麼?

+0

,什麼是問題? – khmarbaise

+0

這可能是maven存儲在計算機上的路徑嗎?無論命令'mvn'是指向 – AK47

+0

@khmarbaise我的問題基本上是如何在python腳本中運行這個(上面提到的)maven命令。 – Arshad

回答

0

(Linux)的用於MVN二進制文件搜索:

$ which mvn 
/c/Maven/apache-maven-3.0.5-bin/apache-maven-3.0.5/bin/mvn 

,並設置這個在您的腳本:

MAVEN_BINARY ='/c/Maven/apache-maven-3.0.5-bin/apache-maven-3.0.5/bin/mvn' 
相關問題