How to figure out when Azure DevOps release pipeline is over using REST Api? - azure-devops

I have a script that triggers a Build. That build is followed by a Release pipeline. In my script I can figure out what is the url for the Release, but I do not understand how can the script decide when the release pipeline is done.
Suppose, there are no interactive approvals. Still:
The release status seems to be stuck on "active", does not matter if all the stages have already converged to some final status.
The stages can be "notStarted", "inProgress", "rejected", "cancelled" or "succeeded".
I suppose it is possible to figure things out by doing some analysis on the state of all the stages while taking into account the topology of the pipeline, but that seems to be too complicated.
Is it possible at all to wait in a script until some release gets into a final state, from which no change is possible?
EDIT 1
I am OK writing a polling loop. This is what I do to figure out when a build is over. But for releases, I have a problem with the stop condition - I just do not know what it is.
EDIT 2
Consider the following pipeline:
+---> A
/ \
Start + -[Promoted only if (*) is true]-> C ---> D
\ /
+---> B
(no manual approvals)
Now suppose the build does not satisfy the condition (*) and so the release effectively stops after running on A and B, but not C. The statuses on environments would be:
A = succeeded or rejected
B = succeeded or rejected
C = notStarted
D = notStarted
So, what is the stop condition for the waiting loop that would stop it in this situation? Is it possible to do it without discovering the topology of the release pipeline?

Unfortunately, there aren't any blocking API calls. You'll need to write a loop in (eg PowerShell) to check for changes in status.
There are two "status" fields in a Release.
The first is the overall status of a Release, for example, it was deployed into two environments before it was marked as "abandoned" and no longer a release candidate for production. You can set this status in the UI by selecting the Release and selecting "Abandon".
The second status is for each environment being deployed. Each ReleaseEnvironment has an EnvironmentStatus. Surprisingly, there isn't a "failed" state there, but you're interested in anything that isn't "notstarted" and is "succeeded". (Perhaps partiallySucceeded is an indicator that something failed without flagging the entire environment as failed?).
There is a third status that you might need to consider if you have pre-deployment or post-deployment approvals enabled. These are in the preDeployApprovals status (ApprovalStatus) and postDeployApprovals nodes.

Related

fly watch on current job inside on_error?

I want to get the results of the fly watch command for the current build on the on_error hook so I can report the details of the error into Slack.
I found a way to do this using a custom resource, however, since the job is still running during the on_error, it just loops endlessly which effectively hangs the concourse build and VM.
Is there a way to get the fly watch output for a pipeline? Alternatively, is there a way to tell the fly watch command to just return the data is has and not continue to query for more output?

Meaning of actions in seize block

Would like to understand what is the difference between "On seize unit" and "On prepare unit"? I tried looking up the Anylogic help, but it does not explain anything there. Also, what does "On remove" mean?
You can link "Preparation" branches into your Seizeobject. See https://anylogic.help/library-reference-guides/process-modeling-library/resourcetaskstart.html#resourcetaskstart
onSeize is executed when a resource is being seized, i.e. before preparation (if you have a prep branch)
opPrerareUnit is executed when the seized resource finished its prep branch and is just about to start servicing the agent.
You can always test yourself by using some traceln texts in those code fields to see when and how they execute

Abort second job activity if first one aborts

I want abort 2nd job activity if 1st job activity aborts due env. issue or manual abortion.
I gone through the triggering option but couldn't get.
Can anyone help me ?
OK, You can't abort a job without running it. So you would need to be able to invoke Job 2 with knowledge of Job 1 status (e.g. from activity variable Job1.$JobStatus). This could be used to cause Job 2 to abort.
The cleanest solution would be a before-job subroutine, which sets its return code to 0 if Job 1's status was DSJS.RUNOK or DSJS.RUNWARN (these are DataStage constants), or to a non-zero value if Job 1's status was DSJS.RUNFATAL or any other value. This is the cleanest approach because the before-job subroutine could write a message to the job log indicating precisely why the job was being aborted.
A less clean way would be to have a parameter in Job 2 of type, say, Integer (anything other than string), and set its value in the Job Activity using an expression such as If Job1.$JobStatus = DSJS.RUNFATAL Then "" Else 1 - setting a non-string parameter to "" will cause the job to abort with DSJE.PARAMBADVALUE error.
You will need to show us exactly what you did. The use of trigger, which I explained earlier, is the correct solution. If you did it correctly, the arrow on the design canvas should be red.
Alternatively you could change your sequence to bypass Job 2 entirely, and instead simply log a message that Job 2 was being bypassed because Job 1 aborted.

How to configure workflow runtime (Informatica)?

I would like the workflow to run for 20 minutes....If the running process does not complete within 20 minutes, the workflow should be ended immediately..However, I can only find the timer, but it is used for starting the process after the indicated time which is not I'm looking for...Does anyone know how to specify the duration for the workflow?
[updated to cover complete scenario and cover issues raised by Koushik Sinharoy in comments]
You can achieve it using the timer:
Link one to the Start task and set it to run for 20 minutes in
parallel with your session.
Have a Decision task with Treat the input links as set to OR. This will trigger the decision whenever any of the preceeding task ends, so either your session will get completed or timer runs out (whatever happens first).
Set the Decision condition to $s_your_session.Status = SUCCEEDED.
Link the Decision task to Control Task.
Set Control task to Fail parent.
Add a condition $Decision.Condition = False to the link between Decision task and Control task.
This should be the result:
Start--->s_your_session--\
\ > Decision [OR] ---(False)---> Control Task [Fail parent]
\-->timer-----------/
Thanks Koushik Sinharoy for the remarks below!

Trouble with agent state chart

I'm trying to create an agent statechart where a transition should happen every day at 4 pm (except weekends).
I have already tried:
1. a conditional transition (condition: getHourOfDay() == 16)
2: A timeout transition that will "reinsert" my agent into the chart every 1 s and check if time = 16.
My code is still not running, does anyone have any idea how to solve it?
This is my statechart view. Customer is a single resource that is supposed to "get" the products out of my stock everyday at 4pm. It is supposed to happen in the "Active" state.
I have set a timeout transition (from Active-Active) that runs every 1s.
Inside my "Active" state in the "entrance action" i wrote my code to check if it is 4 pm and run my action if so.
I thought since i set a timeout transition it would check my condition every 1s, but apparently it is not working.
Your agent does not enter the Active state via an internal transition.
Redraw the transition to actually go out of the Active state and then enter it again as below:
Don't use condition-based transitions, for performance reasons. In your case, it also never triggers because it is only evaluated when something happens in the model. Incidentally, that is not the case at 4pm.
re your timeout approach: Why would you "reinsert" your agent into its own statechart? Not sure I understand...
Why not set up a schedule or event with your recurrence requirement and make it send a message to the statechart: stateChart.fireEvent("trigger!");. In your statechart, add a message-based transition that waits for this message. This will work.
Be careful to understand the difference between the Statechart.fireEvent() and the Statechart.receiveMessage() functions, though.
PS: and agree with Felipe: please start using SOF the way it is meant, i.e. also mark replies as solved. It helps us but also future users to quickly find solutions :-) cheers