Uploading artifact to a release was working on 2018.5

As part of the deployment process in jenkins we have a powershell script that after creating a release in octopus, it uploads other artifacts (metadata files) to the release just created via the Octopus API. This was working fine when using the version 2018.5 and doing these API calls:

POST /artifacts
{
            Filename = $ArtifactName
            RelatedDocumentIds = @($OctopusProjectId, $ReleaseId)
}
PUT artifacts/$ArtifactId/content
...content of the file...

Since upgrading to the version 2019.3.0 we are getting the following 500 error response when doing the same API call to POST /artifacts:

{
  "ErrorMessage": "Object reference not set to an instance of an object."
}

From the logs:

2019-06-17 11:54:58.7307   1548     64 ERROR  Unhandled error on request: https://octopus-server/api/artifacts a0df6f3b72a240478d9061fe8903abd7 by *** : Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Octopus.Core.Validation.ArtifactValidator.BeAnAdhocScriptOrDeploymentTask(Artifact artifact, String relatedDocumentIds)
   at FluentValidation.Validators.PredicateValidator.IsValid(PropertyValidatorContext context)
   at FluentValidation.Validators.PropertyValidator.Validate(PropertyValidatorContext context)
   at FluentValidation.Internal.PropertyRule.<Validate>d__59.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at FluentValidation.Results.ValidationResult..ctor(IEnumerable`1 failures)
   at FluentValidation.AbstractValidator`1.Validate(ValidationContext`1 context)
   at Octopus.Server.Web.Infrastructure.Api.Responder`1.ValidateModel[TModel](IEnumerable`1 validators, TModel model)
   at Octopus.Server.Web.Infrastructure.Api.CreateResponseDescriptor`2.Responder.ExecuteRegistered()
   at Octopus.Server.Web.Infrastructure.Api.Responder`1.Respond(TDescriptor options, NancyContext context)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Octopus.Server.Web.Infrastructure.OctopusNancyModule.<>c__DisplayClass14_0.<get_Routes>b__1(Object x)
   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)

Any suggestion in what we should change? Is the functionality still available?

Thanks,
Alex

Hi Alex,

Thanks for getting in touch!

We have made a slight change here which is what is tripping you up. As of 2019.1 we now require a ServerTaskID property which we called out as a breaking change in our release notes

Artifacts
Artifacts (Artifactresource) no longer contains RelatedDocumentIds. Instead there is a new property called ServerTaskId to indicate which ServerTask the Artifact was collected from. Artifacts can only be associated with AdHoc Script tasks and Deployment tasks.

Sorry that this wasn’t as easy to find as it should be. I’ve included the API call as shown in Swagger which should assist as well.

{
  "Id": "string",
  "SpaceId": "string",
  "Filename": "string",
  "Source": "string",
  "ServerTaskId": "string",
  "Created": "2019-06-18T00:59:12.628Z",
  "LogCorrelationId": "string",
  "LastModifiedOn": "2019-06-18T00:59:12.628Z",
  "LastModifiedBy": "string",
  "Links": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  }
}

Any questions please let me know.

Regards,
Alex

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.