Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

BuildMaster - Error creating build and release from API



  • When trying to access the API to create a build, a release and deploy, you receive a number of errors that don't meet the specification:

    Ok, lets start by getting the releases of all the applications

    Invoke-WebRequest -Uri "http://localhost:8622/api/releases?key=test" -Method Get
    
    #Invoke-WebRequest : Object reference not set to an instance of an object.
    #At line:1 char:1
    #+ Invoke-WebRequest -Uri http://localhost:8622/api/releases?key=test -M ...
    #+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    #    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

    Never mind, that didn't work, so instead lets go ahead and create a release against application ID by sending that in the POST body

    
    Invoke-WebRequest -Uri "http://localhost:8622/api/releases/create?key=test" -Method POST -Body (@{ "applicationId" = 1 } | ConvertTo-Json)
    #Invoke-WebRequest : An application name or ID is required.
    #At line:11 char:1
    #+ Invoke-WebRequest -Uri http://localhost:8622/api/releases/create?key= ...
    #+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    #    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

    Oh, that didn't work. Never mind, let's send it via Params instead!

    Invoke-WebRequest -Uri "http://localhost:8622/api/releases/create?applicationId=1&key=test" -Method POST
    #Invoke-WebRequest : A pipeline name or ID is required.
    #At line:19 char:1
    #+ Invoke-WebRequest -Uri "http://localhost:8622/api/releases/create?app ...
    #+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    #    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

    Ah I forgot the pipeline ID, so that's add that in. Only I don't have the ID because GET doesn't work so lets instead use the name

    Invoke-WebRequest -Uri "http://localhost:8622/api/releases/create?applicationId=1&pipeLineName=Default%3A%3Atest%3A%3APipeline%3A%3ARelease&key=test" -Method POST
    #StatusCode        : 200
    #StatusDescription : OK
    #Content           : {"id":1,"number":"0.0.0","name":"0.0.0","sequence":1,"status":"active","createdBy":"API","createdOn":"2024-02-02T19:34:11.5330000Z","applicationId":1
    #                    ,"applicationName":"test","pipelineName":"Default::...
    #RawContent        : HTTP/1.1 200 OK
    #{"id":1,"number":"0.0.0","name":"0.0.0","sequence"...
    
    

    nice that worked! So lets create a build in that release

    Invoke-WebRequest -Uri "http://localhost:8622/api/releases/builds/create?applicationId=1&releaseId=1&key=test" -METHOD POST
    #StatusCode        : 200
    #StatusDescription : OK
    #Content           : {"id":1,"number":"1","status":"active","createdBy":"API","createdOn":"2024-02-02T19:35:59.5570000Z","applicationId":1,"applicationName":"test","pipel
    #                    ineName":"Default::test::Pipeline::Release","releas...
    

    Nice that worked too. We are getting somewhere here. Lets try and go and see that build in the web GUI so we can check progress before doing a deployment

    Uh oh..........

    3cbc5d7d-e69a-480b-a5ff-528884f15150-image.png

    Ok, lets try and create another build manually instead

    8de80102-105b-4329-be71-43e138abc00f-image.png

    232085f9-291e-4b47-96da-bf969236624b-image.png


  • inedo-engineer

    Hi @Jon,

    The Release and Build API Documentation is outdated and needs a lot of work. We are aware of the low-quality documentation, and this is on our list to rewrite.

    To address your issues.

    [1] The error for "/api/releases" should be logged under Admin > Diagnostic Center; it's likely related to an unexpected/missing data in the application; you can narrow it down by specifying application id or something

    [2] You'll need to specify application/json as the content type when posting JSON documents; otherwise the request will be read as application/x-www-form-urlencoded values or querystring parameters.

    [3] The pipeline name is incorrect, it should simply be Release (for an application pipeline) or global::MyGlobalPipeline for global pipelines.

    Thanks,
    Alana


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation