Skip to end of metadata
Go to start of metadata

Plugin Information

View Nexus Artifact Uploader on the plugin site for more information.

This plugin goal is to upload artifacts generated from non-maven projects to Nexus

This plugin now supports Nexus-2.x & Nexus-3.x.

Used to upload non maven artifacts to Nexus.

Uploading maven artifacts snapshots is not supported by this plugin.

Job DSL example

freeStyleJob('NexusArtifactUploaderJob') {
    steps {
      nexusArtifactUploader {
        nexusVersion('nexus2')
        protocol('http')
        nexusUrl('localhost:8080/nexus')
        groupId('sp.sd')
        version('2.4')
        repository('NexusArtifactUploader')
        credentialsId('44620c50-1589-4617-a677-7563985e46e1')
        artifact {
            artifactId('nexus-artifact-uploader')
            type('jar')
            classifier('debug')
            file('nexus-artifact-uploader.jar')
        }
        artifact {
            artifactId('nexus-artifact-uploader')
            type('hpi')
            classifier('debug')
            file('nexus-artifact-uploader.hpi')
        }
      }
    }
}

Release 2.10 (13 August 2017)

  • [JENKINS-46109] Fixed 404 errors in configure page with Dropdown controls.
  • [JENKINS-45995] Trim artifact filename when spaces added by mistake.

Release 2.9 (13 December 2016)

  • [JENKINS-39594] Fixed frequent, intermittent "Failed to deploy artifacts".

Release 2.8 (21 November 2016)

  • [JENKINS-38950] Added support for uploading multiple artifacts.

Release 2.7 (15 October 2016)

  • [FIXED JENKINS-38918] Build is not failing in pipeline on failed upload.

Release 2.6 (08 October 2016)

  • [JENKINS-37960] Added support for Nexus-3 version to upload artifacts.

Release 2.5 (30 September 2016)

  • Added DSL support and above is the example to use this plugin.

Release 2.4 (20 August 2016)

  • Added support for entering classifier and type.
  • [JENKINS-37536] - Fixed null pointer exception when passing folder level credentials.

Release 2.3 (28 July 2016)

  • Upgraded Credentials plugin to 2.1.0.

Release 2.2 (24 May 2016)

  • Added support for Jenkins Pipeline.
  • Added "nexusArtifactUploader" as pipeline step.

Release 2.1.2 (06 April 2016)

  • Fixed protocol issue when configured HTTPS it resets to HTTP

Release 2.1.1 (05 April 2016)

  • Added empty option to Jenkins Credentials

Release 2.1 (03 April 2016)

  • Added Jenkins Credentials to pass username and password

Release 2.0 (13 March 2016)

  • Removing the dependency with TokenMacro for resolving environment variables used Jenkins method to resolve.
  • Added help text for the important fields.
  • Added error message from server when failed to upload to nexus.
  • Added uploaded artifact link in side bar.
  • Changed name of the plugin from "Upload artifacts to nexus" to "Nexus Artifact Uploader"

Release 1.1 (07 March 2016)

  • Fixed Uploading files from Slave machines.
  • Fixed validation issue with Nexus Url

Release 1.0 (06 March 2016)

  • First public release

38 Comments

    1. As I mentioned already this gives option to upload artifacts generated from Non-Maven projects. As we mention repo username and password in M2 settings file only,

      where as for Non Maven Projects we don't have pom.xml and also we need Maven needs to be install in each slave.

      In our case we are using Nexus as Package repository for storing the application artifacts by taking advantage of versions and grouping classification of Maven Nexus.

      Nexus plays a major role in our tool stack for various technologies like .Net, Java, PHP, ruby and so many technologies where we get package as Repository.

      Hope I have answered for your question.

      If any mistakes in my English, Pls don't mind.

      1. Repository Connector allows for that as well ... there's a few pull requests that make it happen, just have to merge them yourself and build : https://github.com/jenkinsci/repository-connector-plugin/pulls

        I use it for a lot of non-Maven projects and works great.

        To each their own.

        1. Hi Brenton

          I am looking for a way to upload artifacts to Nexus 2, MSBuild by Jenkins of .net applications. With Repository Connector plugin, the Artifact Resolver downloads the artifact from Nexus and deploy to the remote server, which is the opposite way. How can I use it to upload to Nexus?

          Thanks

          Jirong 

          1. To avoid hijacking this plugin's comment section, best to ask that over on the Repo Connector's page.

  1. I got this error, there is no detail error messages. The UI in Jenkins has no help message. Can you give a sample Nexus URL? The REST API URI doesn't seem right? /service/local/artifact/maven/content. Should it be something like this? "/nexus/service/local/repositories/$repo/content/$groupIdPath/$artifactId/$version/"

    Started by user admin
    EnvInject - Loading node environment variables.
    Building on master in workspace C:\Tools\Jenkins\jobs\DevOps\jobs\Upload\workspace
    GroupId: devops
    ArtifactId: support-20160216-131215-1.zip
    Version: 1.0
    File: support-20160216-131215-1.zip
    Repository:Releases
    Uploading artifact support-20160216-131215-1.zip started....
    Build step 'Upload artifacts to nexus' marked build as failure
    Finished: FAILURE

    1. Hi Jirong,

      I will add help in the next release, that is 2 weeks later.

      Thanks for your feedback.

      If the  Nexus Rest API Url is  http://mynexusrepo:8081/service/local/artifact/maven/content We have to enter only mynexusrepo:8081 in the Nexus Url field.

      One more example, if the Nexus Rest API Url is http://mynexusrepo:8081/nexus/service/local/artifact/maven/content We have to enter only mynexusrepo:8081/nexus in the Nexus Url field.

      I think this helps you.

      Thanks,

      Suresh

      1. Finally get it work. The Repository is using the repository id, not name. More suggestions:

        1. Give more details in the error message.

        2. Use Jenkins credentials instead of put in id and password here.

      2. I got it working as shown below. The problem is the Repository field is using id not name. Now can you please modify the user and password using Jenkins credentials? We can't use pain id and password here. Thanks.

  2. I've noticed that the protocol resets itself to HTTP from HTTPS whenever you Configure the Jenkins job.

    Can we get the protocol to stay as HTTPS?

    Thanks.

  3. I have problem to use variables in the version field:

    D:\public_jendevslave_1\workspace\DevOps\AdminTasks\GitHub-SuspendInactiveADAccounts-2>exit 0
    githubSuspsendInactiveADAccounts_1.0.0.%BUILD_NUMBER%.zip file doesn't exists
    ERROR: flexible-publish Upload artifact to nexus (sp.sd.nexusartifactuploader.NexusArtifactUploader@1170ce2) aborted due to exception
    java.io.IOException: githubSuspsendInactiveADAccounts_1.0.0.%BUILD_NUMBER%.zip file doesn't exists

    1. Hi Jirong Hu,

      You have to pass Version as 1.0.0.$BUILD_NUMBER.zip

      So the build variables will be expanded at the time of execution.

      Regards,

      Suresh

  4. (edited - this post is directed to Suresh)

    Hi Suresh,

    I'm trying to use this plugin to upload Windows/.NET application files (.config, .dll, etc.) in a .zip artifact and I'm able to do it when uploading to 'releases' repository; but I'm getting an error when uploading to the snapshot repository:

    "This is a Maven SNAPSHOT repository, and manual upload against it is forbidden!"

    I'm already appending -SNAPSHOT to the version number so I'm not sure what else I might need to do to make it work.  Any ideas?

    Regards,

    GR

    1. You can't manually upload to a Maven snapshot repo. It's by design:https://issues.sonatype.org/browse/NEXUS-3384

  5. When I upload from 2.2 to 2.3, it's asking a reboot, I guess it's restart Jenkins. But still why, I see most of plugin install doesn't require a restart. 

    1. For first time installation of some plugins restart doesn't require, but when ever plugin upgrade happened restart is must to get the upgraded changes.

  6. Hi Suresh

    When we use this plugin in the pipeline, we got a NullPointerException, we want to use credentials (created in the same folder as the pipeline project so other people can't use), as shown below. We are using Jenkins 2.7.1.

    stage 'Promote'

    nexusArtifactUploader artifactId: a, credentialsId: '03061789-shortened-1ed6f456', file: a + '.zip', groupId: g, nexusPassword: '', nexusUrl: 'invnexus.mycompany.com/nexus', nexusUser: '', packaging: 'zip', protocol: 'http', repository: 'otpp-releases', version: new_version

    D:\public\workspace\Release\Promote@2>Powershell -Command "Add-Type -Assembly System.IO.Compression.FileSystem; System.IO.Compression.ZipFile::CreateFromDirectory(\"stage\", \"pmer.zip\", System.IO.Compression.CompressionLevel::Optimal, $false)" Pipeline nexusArtifactUploader
    Pipeline }
    Pipeline // ws
    Pipeline }
    Pipeline // node
    Pipeline End of Pipeline
    java.lang.NullPointerException
    at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep.getUsername(NexusArtifactUploaderStep.java:153)
    at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep$Execution.run(NexusArtifactUploaderStep.java:276)
    at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep$Execution.run(NexusArtifactUploaderStep.java:250)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
    at hudson.security.ACL.impersonate(ACL.java:213)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(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

    1. Hi Jirong Hu,

      Which version of plugin your using.

      And also raise a ticket in JIRA, for future tracking purposes.

      -Suresh

  7. We are using the latest 2.3. JIRA has been created: https://issues.jenkins-ci.org/browse/JENKINS-37554. Appreciate if you can look into this asap, it's blocking our delivery. Thanks!

    1. Hi Jirong Hu,

      Today 2.4 version released with the fix and a new feature support for entering type & classifier. I think it takes a while to reflect the release in update center.

      -Suresh

  8. Hi Suresh Kumar,

    Need some suggestion on one of the option i.e, v - version

    What is the recommended format for this? Can I use "1.0" or "LATEST"

    Thanks in advance.

    1. It's all depends on how you want your artifacts stored in repository. Several parameters has to taken into consideration while designing.

    2. Recommended format is either static or incremental pattern. i.e "1.0" or "$BUILD_NUMBER"

      1. Thanks for the reply Suresh, I have tried the both formats but the output shows like "The version 1.0 does not match the repository policy!"

  9. Hi Suresh

    I can see below error as soon as my build is successful. I would like to upload the artifact once the build is successful. Can you please advise ?:check
    :build

    BUILD SUCCESSFUL

    Total time: 47.365 secs

    This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.12/userguide/gradle_daemon.html
    Build step 'Invoke Gradle script' changed build result to SUCCESS
    account-val-svc-1.0-SNAPSHOT.jar file doesn't exists
    FATAL: account-val-svc-1.0-SNAPSHOT.jar file doesn't exists
    java.io.IOException: account-val-svc-1.0-SNAPSHOT.jar file doesn't exists
    at sp.sd.nexusartifactuploader.NexusArtifactUploader.perform(NexusArtifactUploader.java:180)
    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
    Finished: FAILURE

  10. Hi Suresh.

    I am using this plugin with all dependencies. I have a Visual C++ exe file that I have wrapped in a zip file. But when I use this plugin from jenkins, and enter the user ID and password (either on the fields or through the credentials storage plugin) I always run into 403 Forbidden Error. Please see that is it NOT a Maven project. I have kept my artifact name something like Test-1.0.7-SNAPSHOT.zip.

    My Version that I have kept is 1.0.7.

    Can you please help here?

    Thanks

    Ashutosh

    1. Hi Ashutosh,

      Check in which repo you are uploading don't use the snapshot or release repos, as they work with maven project types. Create a maven hosted repo and upload the artifacts, make sure to remove the snapshot word in artifact file names.

      -Suresh

      1. Thank you so much Suresh for replying here. Well I have tried all those possibilities and got it checked. The deal is that if its a Maven project (Java side) it works fine with same user id and same repositories, but while doing it through this plugin with same user id and repository, it fails. 

        THe only workaround that I did now is using Maven command with a custom pom.xml for my C++ project. I kind of hate mixing Java and non Java projects this way as I wanted something that is out of Ant/Maven but seems like  I am in a fix because of this.

        THanks

        Ashutosh

  11. Hey there Suresh,

    Just wondering where the plugin is looking for the files? Is it in the last successful file? because we keep getting the error: archive.zip file doesn't exists

    But we created it in the step before. The file "archive.zip" exists in the jobs folder, so I guess it is there, but I still get the same error when i specify the entire path. Our command is:

            nexusArtifactUploader artifacts: [[artifactId: 'ECertImport_Build', classifier: '', file: 'archive.zip', type: 'zip']], credentialsId: '', groupId: 'nuget-group', nexusUrl: '172.17.100.115', nexusVersion: 'nexus2', protocol: 'http', repository: 'nuget-releases', version: '2.14'

     nexusArtifactUploader artifacts: [[artifactId: 'Build_artifacts', classifier: '', file: 'archive.zip', type: 'zip']], credentialsId: '', groupId: 'nuget-group', nexusUrl: 'xxx.xx.xx.xxx', nexusVersion: 'nexus2', protocol: 'http', repository: 'nuget-releases', version: '2.14'
    

    Cheers,

    Ollie.

  12. How do I set a GroupId for a raw repository?

    I can not find a Nexus 3 setting to add a GroupId to a raw repository, and this plugin requires a GroupId to be specified.

    1. John

      Plugin supports only Maven type repositories in Nexus.

      -Suresh

  13. Hi Suresh,

    Will I able to upload nuget package to Nexus repo using this plugin?

    I am trying to do but Jenkins build fails saying:

    10 % completed (102 kB / 989 kB).
    20 % completed (201 kB / 989 kB).
    Failed to deploy artifacts: Could not transfer artifact 

    Thanks,

    Tadul Shah.

    1. The plugin's main goal to upload artifacts into Maven type repository using GAV parameters.

  14. How do you use this plugin if you have a Nexus-3 and it is configured to require usertoken? I can not see that the name nor password/token is passed to the Nexus application when viewing the log 

  15. Hi.  I'm unable to upload a tar file or a .tar.gz or .tar.gz to a maven repository.  I'm able to upload from command line using mvn deploy:deploy-file.  I'm getting the error 

    Return code is: 500, ReasonPhrase:Server Error.

    I'm able to upload a bin file, txt file just fine.  I'm using version: 2.10

  16. Hi,
    When deploying artifacts to Nexus Repo using Nexus artifact Uploader plugin, it doesn't generate maven-metadata.xml under artifactID. It is generating only under version, so we are unable to resolve the versions available in an artifactID.
    Can you please help on this.


    Thanks
    -Karthik

    1. Hi Karthik, 

      I am facing the exact same issue, did you find a way to resolve it, if so please share the steps you followed to resolve. 


      TIA 

      Sathish

  17. What will it take to get this working with other repository types that Nexus 3 provides, for example "npm", "nuget", "docker", and "pypi"?