How do I get the build Labels set, using the api? (OD-2512)
Brent Hitzeroth opened 5 months ago

Currently I don't seem to be getting any return values when using "/~api/builds/{buildId}/labels"?

  • Robin Shen commented 5 months ago

    Please upgrade to latest version, it does return labels added to specified build.

  • Robin Shen changed state to 'Closed' 5 months ago
    Previous Value Current Value
    Open
    Closed
  • Brent Hitzeroth commented 5 months ago

    This issue is still there in the new version

  • Brent Hitzeroth changed state to 'Open' 5 months ago
    Previous Value Current Value
    Closed
    Open
  • Brent Hitzeroth commented 5 months ago

    I have tested this in the latest version v12.0.4 and I get a successful result but no labels returned. Am I missing something? see below. I expect to get the "SyncAll" label returned.

    image.png

    var response = await _client.GetAsync($"/~api/builds/171/labels");
    
  • Brent Hitzeroth commented 5 months ago

    Hi Robin I realised that I was getting confussed with the buildId and buildNo.

    1. In this query I used the "Query Builds" api function and the result returns Id = 606 and No = 178

    string query = $"\"Project\" is \"{projectName}\"";
    string encodedQuery = Uri.EscapeDataString(query);
    var response = await _client.GetAsync($"/~api/builds?query={encodedQuery}&offset=0&count=1");
    

    image_2.png

    2. In this query I used the "Get Build" api function with input parameter = 178 (buildId according to documentation), and the result returns Id = 178 and No = 28

    var response = await _client.GetAsync($"/~api/builds/178");
    

    image_4.png

    So I am a bit confused about the numbering but if I use 606 as buildId in the "Get Labels" api call, I do get labels returned. I was using 178 before which I think is actually the build number. Could you please clarify this for me, or am I looking at it wrong?

  • Robin Shen commented 5 months ago

    Build id and build number is different thing. Build number is what being displayed at the UI and it is only unique inside project. Different projects may have builds with same build number. Build id is used by OneDev internally to identify a build, and it is unique across the whole instance.

    The GetBuild api expects build id instead of build number. Build id can be queried with project and build number with below query:

    "Number" is "<project path>#<build number>"
    

    Or if your project has a key specified, with below query:

    "Number" is "PROJKEY-<build number>"
    
  • Brent Hitzeroth commented 5 months ago

    Thank you for that clarification.

  • Brent Hitzeroth commented 5 months ago

    Able to query Labels successfully.

  • Brent Hitzeroth changed state to 'Closed' 5 months ago
    Previous Value Current Value
    Open
    Closed
issue 1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2512
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover