Unknown
Unknown

Reputation: 77

Azure DevOps ( On-premises ) | Configuration Build Process & Docker Image creation for Nexus Repository

iam new with the topic Azure DevOps & Nexus Repository. My code is committed on Azure DevOps On-premises. And the way Azure DevOps and Azure registry works fine.

But now i struggle with configuration Nexus, does i need this tutorial ? https://devblogs.microsoft.com/devops/nexus-build-extension-for-team-services/

When yes where i get information for this properties:

because those properties are needed for configuration that. After i speaking with my Nexus colleuges he mean its look like Maven configuration.

So maybe the way is wrong ?

Conclusion what i want to achive:

After i have committed my code in Azure DevOps On-premises, i want to configure a build process that create a docker image which move this into nexus repository.

Kind regards,

Unknown

Upvotes: 0

Views: 599

Answers (1)

Mengdi Liang
Mengdi Liang

Reputation: 19016

No, not wrong.

We have open the source of this extension in Github, see this vsts-nexus repos.

Before the code analysis, we need to know the logic of it. In this extension, we achieve the feature uploading the file to Nexus Repository Manager with Nexus 2.x Rest API, which URI is:

https://local:8081/service/local/artifact/maven/content?r={xx}&g={xx}&a={xx}&v={xx}&p={xx}&c={xx}" > xxx.jar

In this URI, r is repositoryId, g is groupId, a is artifactId, v is artifactVersion, c is classifier, p is packaging. That's why your colleague think its look like Maven configuration, because we are using this API as the logic of extension.

See this script file: NexusTask.ts.

var nexusUploadUrl = Util.addUrlSegment(serverEndpointUrl, 'service/local/artifact/maven/content');
tl.debug('nexusUploadUrl=' + nexusUploadUrl);
     ...
     ...
     ...
var formData = {
    // Pass a simple key-value pair
    r: repositoryId,
    g: groupId,
    a: artifactId,
    v: artifactVersion,
    c: classifier,
    p: packaging,
    e: extension,
    // Pass data via Streams
    my_file: fs.createReadStream(fileName)
};

var postData: any = { url: nexusUploadUrl, formData: formData, strictSSL: !trustSSL };

This is the short section of script. You can get clearly know the API and its parameters what the extension used.

So, there's no wrong on this extension and task, just its logic is using the Nexus 2.x API.

But, you need to pay attention about this extension only support Nexus 2.x until now. If what you are using is Nexus 3.x, you'd better use a Maven pom.xml file to upload an artifact into Nexus via Nexus' Maven support.

As what you want is build a docker image then upload it to Nexus, you can use Docker task to build the docker image, then use this task or Maven to upload this image to Nexus.

Upvotes: 2

Related Questions