yeah I posted some stuff, which seems to not have posted correctly which 
was odd. basically i had a few json objects that didnt match what I 
expected.. but figured that out, typed the answer in my last message. 

On Tuesday, February 23, 2021 at 11:14:45 PM UTC+13 Gabriel Callaghan wrote:

> ok i think i have the wrong approach to this problem..
>
> so when im doing stage history, it's not in order. because if an earlier 
> instance is run, that goes to the top of the stage history, even tho I only 
> want to approve the most recent instance. also stage history doesn't show 
> the stage history of an instance that hasn't had a stage run yet, so it 
> won't show up to run. 
>
> so I need to rethink the soloution to this problem. 
>
> On Tuesday, February 23, 2021 at 10:33:54 PM UTC+13 Gabriel Callaghan 
> wrote:
>
>> hi just checking, did you delete the message I wrote recently? showing up 
>> as message has been deleted, not sure if I deleted by accident.
>>
>> On Tuesday, February 23, 2021 at 10:15:14 PM UTC+13 Marques Lee wrote:
>>
>>> oh also, in the code snippet I sent a couple of messages ago, you may 
>>> want to null check the json blob in case there aren't any matches, for good 
>>> measure.
>>>
>>> that is, do:
>>>
>>> if [ "null" = "$last_stage_result" ]; then
>>>   echo "No pipelines have completed yet" >&2
>>>   exit 1
>>> fi
>>>
>>> On Mon, Feb 22, 2021 at 9:06 PM Marques Lee <[email protected]> 
>>> wrote:
>>>
>>>> Yes, so if you're on say, 20.7.0, just add that to your url: 
>>>> https://api.gocd.org/20.7.0/
>>>>
>>>> It looks pretty similar.
>>>>
>>>> -Marques
>>>>
>>>> On Mon, Feb 22, 2021 at 6:06 PM Gabriel Callaghan <
>>>> [email protected]> wrote:
>>>>
>>>>> I just saw that our GOCD is 20.1.0 so it wouldn't be able to use v3 of 
>>>>> this api, as it requires v20.9.0. So that answers my question for why v3 
>>>>> doesn't work. However in GOCD api list, it only shows v3+, so i cant 
>>>>> check 
>>>>> for what it looks like when using v2. Would anyone know how to get the 
>>>>> most 
>>>>> recent history rather than filtered? I don't want to be only shown passed 
>>>>> results, I want to see failed ones as well.
>>>>>
>>>>> On Tuesday, February 23, 2021 at 1:03:00 PM UTC+13 Gabriel Callaghan 
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am running into some different results than what I wanted. My goal 
>>>>>> is to use jq to filter results of the "get stage history" (
>>>>>> https://api.gocd.org/current/#get-stage-history) so that I can get 
>>>>>> the most recent run and to check it for if it has been passed or not.
>>>>>>
>>>>>> At the moment, I am using that API with v2+ on the third line as it 
>>>>>> provides results. If I change it to v3+, it gets "<html><body><h2>404 
>>>>>> Not 
>>>>>> found</h2></body></html>". This is why I have been using it as v2+. 
>>>>>> However, when using v2+ I am getting back weird results. It does not 
>>>>>> seem 
>>>>>> to be in order from most recent results to the oldest, it is being 
>>>>>> filtered 
>>>>>> somehow? It means that as a result, my script is trying to run a 
>>>>>> pipeline 
>>>>>> that is an older version, when it should be checking and running the 
>>>>>> most 
>>>>>> recent version of a pipeline. 
>>>>>>
>>>>>> Why is it doing that, and what can I do to make sure that the stage 
>>>>>> history json provides results from the most recent to the latest?
>>>>>>
>>>>>> If it helps, my current script is this:
>>>>>>
>>>>>> #! /bin/bash
>>>>>>
>>>>>> fetchPipelineHistory=$( curl "{COMPANY 
>>>>>> NAME}/go/api/stages/Games-AcesHigh-PHY-Test/Approve/history" \
>>>>>>       -H "Authorization: Bearer {MY TOKEN)" \
>>>>>>       -H 'Accept: application/vnd.go.cd.v2+json')
>>>>>>
>>>>>> getResultOfCurrentStage=$( echo $fetchPipelineHistory | jq -r 
>>>>>> '.stages[].result')
>>>>>>
>>>>>> counter=$( echo $fetchPipelineHistory | jq -r '.stages[0].counter')
>>>>>>
>>>>>> if [ "$getResultOfCurrentStage" != "Passed" ]
>>>>>> then
>>>>>>
>>>>>> echo "{COMPANY 
>>>>>> NAME}/api/stages/Games-AcesHigh-PHY-Test/$counter/Approve/run"
>>>>>>
>>>>>> curl "{COMPANY 
>>>>>> NAME}/go/api/stages/Games-AcesHigh-PHY-Test/$counter/Approve/run" \
>>>>>>       -H "Authorization: Bearer {MY TOKEN}" \
>>>>>>       -H 'X-GoCD-Confirm: true' \
>>>>>>       -H 'Accept: application/vnd.go.cd.v2+json' \
>>>>>>       -X POST
>>>>>>
>>>>>> fi
>>>>>>
>>>>>> Thank you for reading,
>>>>>> Gabes.
>>>>>>
>>>>>>
>>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "go-cd" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/go-cd/5cb8a558-ed85-4021-b4ed-564d1d11f460n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/go-cd/5cb8a558-ed85-4021-b4ed-564d1d11f460n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/go-cd/215063c1-53f7-499c-af76-a37651ffeeban%40googlegroups.com.

Reply via email to