Add a Nexus Artifact Source Using API

Updated 4 weeks ago by Archana Singh

This topic describes how to create, read, update, and delete Nexus Artifact Source using Harness GraphQL APIs.

In this topic:

Before You Begin

Step: Create a Nexus Artifact Source

Use this sample query to create a Nexus Artifact Source.

Request

You create a Nexus Artifact Source using the mutation createConnector.

mutation CreateConnector($connector: CreateConnectorInput!) {
createConnector(input: $connector) {
clientMutationId
connector {
...on NexusConnector{
name
id
}
}
}
}
Query Variables

The Query Variables follow this syntax, with connectorType identifying the Nexus Artifact Source to create.

To fetch the passwordSecretId use:

{
"connector": {
"connectorType": "NEXUS",
"nexusConnector": {
"name":"NexusConnector",
"URL":"https://nexus.test.harness.io",
"version":"V2",
"passwordSecretId": "xxxxxxxYYzzz",
"userName": "harnesstest"
}
}
}

Step: Update a Nexus Artifact Source

Use this sample query to update a Nexus Artifact Source.

Request

You update a Nexus Artifact Source using the mutation updateConnector.

mutation UpdateConnector($connector: UpdateConnectorInput!) {
updateConnector(input: $connector) {
clientMutationId
connector {
name
id
}
}
}
Query Variables

The Query Variables follow this syntax, with connectorType identifying the Nexus Artifact Source to update. See Fetch the Connector ID to get the connector ID details.

{
"connector": {
"connectorType": "NEXUS",
"connectorId": "xxxxxyxxxaaaqqq",
"nexusConnector": {
"name":"NexusConnector",
"URL":"https://nexus.test.harness.io",
"version":"V2",
"passwordSecretId": "xxxxxxxYYzzz",
"userName": "harnesstest"
}
}
}
Fetch the Connector ID

Use the following query to fetch the ID of a connector. A list of connectors is returned based on the set filters. You can select the ID of the connector that you want to update.

query
{
connectors(filters: [{connectorType: {operator: EQUALS, values: NEXUS}}], limit: 20) {
nodes {
name
id
}
}
}

Step: Delete a Nexus Artifact Source

You delete a Nexus Artifact Source using the mutation deleteConnector. Deleting a Nexus Artifact Source requires its ID only.

mutation DeleteConnectorMutation($connector: DeleteConnectorInput!) {
deleteConnector(input: $connector) {
clientMutationId
}
}

Query Variables

Query Variables, with connectorId identifies the Nexus Artifact Source to delete.

{
"connector": {
"connectorId": "xxxxxx"
}
}


How did we do?