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/CAPKX9ja5bbA9JXmyecOkaaxhw5dQnpYnvHGbYpmExD%2B_F3YYqA%40mail.gmail.com.

Reply via email to