fly watch on current job inside on_error? - concourse

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?

Related

How can I detach process from Elixir System.cmd/2 before command ends?

I'm trying to run this (script.exs):
System.cmd("zsh", ["-c" "com.spotify.Client"])
IO.puts("done.")
Spotify opens, but "done." never shows up on the screen. I also tried:
System.cmd("zsh", ["-c" "nohup com.spotify.Client &"])
IO.puts("done.")
My script only halts when I close the spotify window. Is it possible to run commands without waiting for it to end?
One should not spawn system tasks in a blind hope they would work properly. If the system task crashes, some actions should be taken in the calling OTP process, otherwise sooner or later it’ll crash in production and nobody would know what had happened and why.
There are many possible scenarios, I would go with Task.start_link/1 (assuming the calling process traps exits,) or with Task.async/1 accompanied by an explicit Task.await/1 somewhere in the supervision tree.
If despite everything explained above you don’t care about robustness, use Kernel.spawn/1 like below
pid = spawn(System, :cmd, ~w|zsh -c com.spotify.Client|)
# Process.monitor(pid) # yet give it a chance to handle errors
IO.puts("done.")

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

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.

How to call the controller task on each 1 min interval

I have created task on controller and there is loop which is loading for 100 times.
Now I want to load it for 25 times and pause that loop for 1 min and after that it will execute next 25 items same for next 25.
I have checked it with sleep but its not working.
Can you please advise me if is there any way on plugin event or any other method.
Thanks
This is actually unrelated to Joomla! Since you're creating a long running process you need to start it with something else than a browser. A CRON job is a good idea here if you want to execute this operation multiple times. Otherwise it can run via command line. Make sure the max_execution time setting of PHP does not cause any trouble.
If you still need this within Joomla please have a look at the CLI documentation.
https://docs.joomla.org/How_to_create_a_stand-alone_application_using_the_Joomla!_Platform

creating task inside other task in freertos

I am an RTOS newbie and I am creating a simple real time system for automotive
I am wondering if it possible to create a task inside another task.
I tried to do this by the following method but it doesn't work.
void vTask1 { *pvParameters){
unsigned portBASE_TYPE taskPriority;
taskPriority=uxTaskPriorityGet( NULL );
char x;
while (1){
x= 5 ;
if (x==5)
xTaskCreate( vTask2 , "task2", 1000, "task2 is running", taskPriority+5 , NULL );
}
when I debug that code it hangs at xTaskCreate without executing the new task
and I searched the manual and the internet for something about this but I didn't find any.
would anyone tell me is that possible to do in RTOS or I am doing it in a wrong way?
Tasks can be created before the scheduler has been started (from main), or after the scheduler has been started (from another task). The xTaskCreate() API documentation is here:
http://www.freertos.org/a00125.html . You will also find a set of demo tasks that demonstrate creating and deleting tasks from another task in the main FreeRTOS .zip file download. Look in the FreeRTOS/Demo/Common/Minimal/death.c file (death for suicidal tasks as they delete themselves after creation).
If xTaskCreate() returns NULL then you will probably have run out of heap space. See http://www.freertos.org/a00111.html. I think most of the hundreds or pre-configured examples that come in the zip file download have comments to this effect.
Check the return value of xTaskCreate api.
one more thing the second task which you are creating is vtask2 which is having lower priority than vtask1 the one who is creating . And vtask1 is running in while(1) scheduler will not schedule vtask2.
you can delay or suspend the vtask1 after creating vtask2.
then vtask2 may execute.

Invoke process activity not logging any error in log file

I am trying to use Invoke process to invoke an executable from my windows workflow in my TFS 2010 build.
But when I am looking at the log file it is not logging any error.
I did use WriteBuildMessage and WriteBuildwarning inside my invoke process activity.
I also set the filename,workingdirectory etc in activity.
Can someone please point out why it is not logging?
You can do something like this:
In this case you have to ensure that Message are set as follows:
With those parameters set as depicted, I catch what you seem to be after.
Furthermore, you can check in the Properties of your InvokeProcess: Set the Result into a string-variable and then set in a subsequent WriteBuildMessage this string-variable to be the Message. This way, you 'll additionally catch the return of your invoked process.
EDIT
Another common thing that you 've possibly overlooked is the BuildMessageImportance: if it is not set as High, messages do NOT appear under default Logging Verbosity (= Normal). See here for some background.
In your Invoke Process, you want to set the Result property to update a variable (returns an Int, so lets call it ExitCode), under your Invoke Process (but still in the Agent Scope) you can drop in an If, so you can set the condition of this to ExitCode <> 0 and do whatever you like on a failure (such as failing the build).
Also, as a note, if your WriteBuildMessage is not showing anything in your log, you need to set the Importance to Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High, anything lower and it wont show in the Normal logging level.