Git Product home page Git Product logo

vsts-nexus's Introduction

Integrate with Sonatype Nexus

This extension provides build tasks that enable you to integrate with Sonatype Nexus 2.x. (Sonatype Nexus 3.x is not supported currently.)

Create a Sonatype Nexus Connection

Create a Generic Service Endpoint and specify your Sonatype Nexus endpoint URL, user name, and password.

Sonatype Nexus Endpoint

Define your build process

Create a build definition to automate your build process. For detailed instructions on setting up a build definition, check out this.

Add the Sonatype Nexus Artifact Upload Build task to your build steps.

Sonatype Nexus Artifact Upload Build Task

Specify the input arguments.

7

License

The code is open sourced under the MIT license. We love and encourage community contributions.

Build pre-requisites

  1. This package requires node and npm

To compile, please run:

  1. npm update
  2. gulp

The vsix package will be produced in _package, and it can be uploaded to Visual Studio Team Services Marketplace for sharing.

FAQ

What if I need to work with Sonatype Nexus 3.x?

The best way to upload artifacts into Nexus 3.x is to use Maven publish capabilities. The quickest way to deploy a file with Maven is described in https://maven.apache.org/plugins/maven-deploy-plugin/usage.html. Tell Maven which file to deploy and define the repository you are deploying to in the pom.xml & settings.xml files. In your pom.xml file add a section describing your release and snapshot Nexus repositories. E.g.

  <repositories>
    <repository>
      <id>teamNexus</id>
      <url>http://public_artifacts_server:8081/nexus/content/repositories/releases</url>
    </repository>
    <repository>
      <id>teamNexus.snapshots</id>
      <url>http://public_artifacts_server:8081/nexus/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

In the settings.xml file specify the credentials that Maven task will use to access Nexus repositories. E.g.

<?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">
  <servers>
    <server>
      <id>teamNexus</id>
      <username>${nexusUsername}</username>
      <password>${nexusPassword}</password>
    </server>
  </servers>
</settings>

Note that the example uses Maven properties for user name and password credentials. These properties can be set in the build task in the secure way using secret variables in your Build/Release. And here’s what the Maven task looks like in the VSTS build definition to run the ‘clean’ and ‘deploy’ goals of the pom.xml to do the deployment:

Maven Artifact Upload Build Task

$(nexusUsername) and $(nexusPassword) are secret VSTS build variables, which should be defined in the Variables section of the build definition:

VSTS secret variables

vsts-nexus's People

Contributors

alexrukhlin avatar davidstaheli avatar microsoft-github-policy-service[bot] avatar msftgits avatar ypupo2002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vsts-nexus's Issues

¿Nexus version 3.0?

Hi guys,

Any idea about when we can use this extensions form Nexus v3.x?

Thanks in advance
Regards
Juanlu

Cannot create a proper vsix from the master branch

Doing:

npm update
gulp

on a local clone of the extension generates a vsix file with missing node_modules:

listing the contents of the archive gives out.1.txt

whether the original vsix gives out.2.txt

My node & npm versions:

λ npm version
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info ok
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
{ npm: '3.9.5',
  ares: '1.10.1-DEV',
  http_parser: '2.5.2',
  icu: '56.1',
  modules: '46',
  node: '4.4.4',
  openssl: '1.0.2h',
  uv: '1.8.0',
  v8: '4.5.103.35',
  zlib: '1.2.8' }
npm info ok

nexus plugin works only for maven repositories

Nexus supports multiple repository types
Maven, Nuget, OBR, NPM, RubyGems and Site (as of Nexus version 2.12)

Currently this plugin only supports Maven repository uploads.
Can the plugin be altered to allow the build to select a valid upload repository for technologies other than maven?

Multiple file upload is not working.

Hi Team,

I am trying to upload multiple file on nexus repo, but it is failing.

Error

##[error]Error: form-data: ENOENT: no such file or directory
I have also tried using the wildcard entries like **/*, *. But still it is failing.
Upload failed. Error: form-data: ENOENT: no such file or directory, open 'D:\a\1\a\**'

Is this the drawback of this plugin?

Nexus url incorrect formatting

Nexus allows custom url formation.
So it's possible to have a url to access nexus with the format http://nexusserver
Using the service endpoint creation (I've logged a separate bug with TFS),
a / will automatically be appended to the service endpoint.
This results in the service endpoint url being http://nexusserver/
The script for the plugin has the following line of code
var nexusUploadUrl = serverEndpointUrl + '/service/local/artifact/maven/content';
this results in a nexus upload url of
http://nexusserver//service/local/artifact/maven/content
which is an invalid url.

Getting in touch

Hello,

I had the same idea as you and I have created the same build task, however, implemented in PowerShell. It is not yet on the marketplace as I was waiting the legal department from SonaType to give me a go to use their logo and name.
As there may not be the need to have two separate plugins, I would like to suggest a couple of things I already have working and I do find handy.

  • Support for Nexus v3 API
  • Support for GAV parameters being loaded from POM file
  • Specific type of service Endpoint
  • Multiple file upload

If you are interested in those and in accepting my work, I would try to implement those in TypeScript.

Packaging input should be a drop-down with set options

The "Packaging" input is a free-text field. This presents 2 problems:

  1. It would be easy for someone to enter an unsupported value
  2. Nexus looks to only support set values: pom, jar, ejb, war, ear, rar, par, maven-archetype, or maven-plugin
    We should make this field a drop-down with set options to make it less-fragile.

Nexus 3.0 Not Supported (its REST APIs do not exist)

I currently have the docker container with nexus 3 installed.
I am able to run the deployment from my local machine with the "mvn deploy" command, but when I attempt to deploy with this extension, I receive the following error:
##[error]Upload failed, HttpResponse.statusCode: 405, HttpResponse.statusMessage: Method Not Allowed

My settings look like:

Do I possibly have the url formatted wrong?
I have tried:
http://name.westus.cloudapp.azure.com:8081/repository/ which gives a 404, not found error.
http://name.westus.cloudapp.azure.com:8081/ which gives "Error: read ECONNRESET"

Need a way to trust the nexus server certificate.

When the Nexus repository is hosted under https, if the certificate issued to the server is not valid, the request to upload the file will fail.
In some cases, there is the need to bypass this behavior, for example, if the certificate is a self signed certificate, or the root certificate authority is an Enterprise Root CA.

Success if upload fails

In this code, it appears the task will succeed if the upload fails. The error handling block should return instead of continuing execution.

request.post({ url: nexusUploadUrl, formData: formData }, function optionalCallback(err, httpResponse, body) {
    if (err) {
        tl.setResult(tl.TaskResult.Failed, err);
    }
    tl.debug('Upload successful, server responded with: ' + body);
    tl.setResult(tl.TaskResult.Succeeded, 'Successfully uploaded ' + fileName);
}).auth(username, password, true);

The "Extension" field allows unsupported input values

The "Extension" input field is currently free-text. It is unclear whether its value should be preceded with a period, such as ".jar" which is the standard format of a file extension. When preceded with a period, it doesn't match one of the supported Packaging field values, and these fields should correlate.

The TypeScript code should strip any preceding period from the file extension so that it correlates with the expected Packaging field values.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.