NuGet and .NET Core Builds with Artifactory - Scripted Pipeline Syntax

JFrog Integrations Documentation

Content Type


We recommend using the integration with the JFrog Jenkins Plugin, rather than using the following DSL.

The Artifactory Plugin's integration with the NuGet and .NET Core clients allow build resolve dependencies, deploy artifacts and publish build-info to Artifactory.


Depending on the client you'd like to use, please make sure either the nuget or dotnet clients are included in the build agent's PATH.

To run NuGet or .NET Core builds with Artifactory from your Pipeline script, you first need to create an Artifactory server instance, as described in the Creating an Artifactory Server Instance section.

Here's an example:

def server = Artifactory.server 'my-server-id'

The next step is to create a NuGet or .NET Core Build instance:

def rtBuild = Artifactory.newDotnetBuild()

// OR

def rtBuild = Artifactory.newNugetBuild()

By default, the build uses NuGet API protocol v2. If you'd like to use v3, set it on the build instance as follows.

rtBuild.setApiProtocol 'v3'

Now let's define where the build should download its dependencies from. We set the Artifactory server instance we created earlier and the repository name on the resolver:

rtBuild.resolver repo: 'nuget-remote', server: server

Now we can download our project's NuGet dependencies, using either the NuGet or .NET Core clients:

def buildInfo = args: 'restore ./src/GraphQL.sln'

The above method returns a buildInfo instance. If we already have a buildInfo instance we'd like to reuse, we can alternatively send the buildInfo as an argument as shown below. Read thePublishing Build-Info to Artifactory section for more details. buildInfo: buildInfo, args: 'restore ./src/GraphQL.sln'

You also have the option of customising the build-info module name associated with this build. You do this as follows:

def buildInfo = args: 'restore ./src/GraphQL.sln', module: 'my-build-info-module-name'

Jenkins spawns a new java process during this step's execution.

You have the option of passing any java args to this new process, by passing the javaArgs argument:

def buildInfo = args: 'restore ./src/GraphQL.sln', javaArgs: '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'

In most cases, your build also produces artifacts. The artifacts can be NuGet packages, DLL files or any other type of artifact. The artifacts produced can be deployed to Artifactory using the server.upload method, as described in the Uploading and Downloading Files section in this article.

You can now publish the build-info to Artifactory as described in the Publishing Build-Info to Artifactory section