x
login Signup

How do I use API to get list of stages in pipeline in the correct order?

I have a pipeline defined with five stages, that run in this order......

Build ==> Smoke Test Deploy ==> Smoke Test ==> Full Test Deploy ==> Full Test

When I try to use the API getStages, and process the stages from the returned XML, they are not in the correct order. This is what my code prints out:

Stage = Build Stage = Full Test Stage = Full Test Deploy Stage = Smoke Test Stage = Smoke Test Deploy

I am trying to determine in my code the name of the Final Stage of the pipeline. Is there a way to determine the final stage, or to get the list of stages in the correct order?

Thanks. - Troy

avatar image By troyklomp 34 asked Oct 02 at 08:47 PM
more ▼
(comments are locked)
10|750 characters needed characters left

1 answer: sort voted first

in the data returned, (XML or JSON), you will find an "index" tag.

    <stage>
       <stageId>33f03322-c04b-11e8-b395-0a03fa837144</stageId>
       <stageName>uat</stageName>
       <completed>0</completed>
       <completionType>auto</completionType>
       <createTime>2018-09-24T22:43:04.271Z</createTime>
       <deployerTaskCount>0</deployerTaskCount>
       <index>3</index>

Use it to sort your stages

avatar image By lrochette 5.8k answered Oct 03 at 09:58 PM
more ▼
(comments are locked)
avatar image lrochette Oct 03 at 09:58 PM

I think by default the API call will return the stages in the order they were created

10|750 characters needed characters left
Your answer
toggle preview:

Up to 8 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.