1

I want to upload an artifact to Nexus using maven in a python script. I looked it up here: https://gist.github.com/adamv/705292

and am doing the following way:

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

But I'm getting undefined variable MAVEN_BINARY. What is this?

Arshad
  • 51
  • 6

1 Answers1

0

(Linux) Search for the binary file for mvn:

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

and set this in your script:

MAVEN_BINARY ='/c/Maven/apache-maven-3.0.5-bin/apache-maven-3.0.5/bin/mvn'
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65