How to create new commands in Zuul CI to trigger custom jobs - zuul-ci

Similar to recheck command, if I want to create custom trigger commands in Zuul CI, what's the best possible way to implement it?
For example, I want to have following 2 commands defined in Zuul to trigger specific tests.
/test-e2e - This would trigger a specific job that runs e2e tests
/test-conformance - This would trigger a specific job that triggers conformance tests.
Can somebody please advise?

Assuming that you are using GitHub to manage you source code you could define a custom regex trigger for you check pipeline
See documentation of pipeline.trigger.<github source>.comment
Something like this:
- pipeline:
name: check
trigger:
github:
- event: pull_request
action: comment
comment: (?i)^\s*test-e2e\s*$

Related

How to get workflow taskId in Alfresco process service using script task

I wanted to get workflow taskId in a script task variable(Java Script/Groovy) and want's display it on user form.
Please let me know if you have any Idea regarding this.
we are using Alfresco process service 1.9 version
Thanks in Advance.
Store the taskId in a process variable using a *ExecutionListener. create a spring bean that implements the activiti Execution Listener, in the overriden method notify(DelegateExecution execution) set your variable like:
execution.setVariable("your_var", your_var_value);
In the Script Task you can access process variables using the Execution. e.g.:
execution.getVariable("your_var");
follow the developer series for more details.

Symfony - background task from form setup

Would you know how to run a background task on Symfony 4, based on the setup of a form ? This would avoid that the user has to remain on the form until the task is finished.
The idea would be that when the form is validated, it starts an independant background task. Then the user can continue its navigation and come back once the task is finished to get the results.
Thanks for your help,
You need to use pattern Message Bus. Symfony has own implementation of this pattern since version 4.1 introducing Messenger Component.
You can see documentation here: https://symfony.com/doc/current/components/messenger.html
To get it work you need some external program that will implement AMQP protocol. Most popular in PHP world IMHO RabbitMQ.
A very simple solution for this could be the following procedure:
Form is valid.
A temporary file is created.
Cronjob gets executed every five minutes and starts a symfony command.
The command checks if the file exists and if it's empty.
If so, the command works of the background task. But before this, the command write it's process id in the file to prevent from beeing excuted a second time.
Remove the file when the command has finished.
As long as the file exists you can show a hint for the user that the task is running.

Symfony2 calling console command in controller from vendor

I want to use a console command from this bundle within my controller: http://knpbundles.com/dizda/CloudBackupBundle
The developer proposes cronjobs, however I want to use the command to backup my database from within my controller.
How would I do that?
I am getting this error message when i simply try to register this command as a service:
You have requested a non-existent service "backupcommandservice".
Thanks for the help!
commands don't quite work that way. Per the note on http://symfony.com/doc/current/cookbook/console/console_command.html#register-commands-in-the-service-container
registering a command as a service doesn't do much other than control location and dependency injection.
if you want to call a command: http://symfony.com/doc/current/components/console/introduction.html#calling-an-existing-command
that being said you shouldn't call commands from within a controller since you're basically asking to wait for this command to finish executing before you return a response. You'd be better off just sending a request to a queue box (for example beanstalk) and have a worker perform the job.

How can I see list of available events in Symfony2

How can I see all available events in Symfony2?
I found a command on google
php app\console container:debug --show-private
But it does not show all available events. Like event named "security.interactive_login" is not listed in it.
Is there a way to see available events?
Console command
You can run:
app/console debug:event-dispatcher
This will show you a detailed summary of every subscriber, in order of priority per event. Unfortunately this won't show you all possible events, since it's infeasible to query the container for any events that could be registered due to the inherently dynamic nature of the events system.
To understand events you'll need to refer to docs and code of each component and bundle.
Documentation is the best place to start
Symfony standard ships with a multitude of events. Each Symfony component and bundle may or may not define events — your best bet is to look at each component or bundle's documentation for references to events.
Some very common events can be found in the docs:
HTTP Kernel Events
Console Events
Form Events
Code analysis
I used PhpStorm to look for all subclasses of Symfony's base Event class (Symfony\Component\EventDispatcher\Event).
I generated an inheritance tree each child is a subclass of it's parent.
* note: prepend Symfony\Component\ to find the FQN
EventDispatcher\Event
EventDispatcher\GenericEvent
Console\Event\ConsoleEvent
Console\Event\ConsoleCommandEvent
Console\Event\ConsoleExceptionEvent
Console\Event\ConsoleTerminateEvent
Form\FormEvent
HttpKernel\Event\KernelEvent
HttpKernel\Event\FilterResponseEvent
HttpKernel\Event\FilterControllerEvent
HttpKernel\Event\FinishRequestEvent
HttpKernel\Event\GetResponseEvent
HttpKernel\Event\GetResponseForControllerResultEvent
HttpKernel\Event\GetResponseForExceptionEvent
HttpKernel\Event\PostResponseEvent
Security\Http\Event\SwitchUserEvent
Security\Http\Event\InteractiveLoginEvent
I make no claim that these are all public events you can/should hook into — this is just one way to programmatic examine 3rd party code and get a sense for potential idioms.
For instance I noticed that both the HttpKernel, Security, and Console components use namespaced constants to expose their keys, see:
Symfony\Component\HttpKernel\KernelEvents
Symfony\Component\Security\Http\SecurityEvents
Symfony\Component\Console\ConsoleEvents
The container:debug command shows all services that are registered to the dependency injection container. With the parameter show-private it will also show services that are flagged with public=false.
So as the most events might not be services the command you are using will not give you a list of available events. But to give you a possibility to search for available events you could try the following command:
php app/console container:debug --show-private | grep -i "listener"
As the most event handlers might have the word listener in their definitions you will find many of them. If you then want to get a more detailed information about the events which are handled by those listeners just call the command with specifying the service ID. For example if you are working with the FOSUserBundle this will give you a description for the interactive login listener:
php app/console container:debug fos_user.security.interactive_login_listener

When or how would I use this.flush() in a Meteor application

I am trying to understand when I might use this.flush() in a Meteor application.
The docs state the following
Call inside publish function. Sends all the pending set, unset, and
complete messages to the client.
If my publish function is something like this
Meteor.publish('myCollection', function(myid){
return MyCollection.find({_id: myid});
});
would I use this.flush()?
What kind of case would one use this.flush() in?
Thanks
S
Not needed in that use case, because Meteor.publish automatically handles the details of how to turn Mongo cursors into the appropriate set and unset commands for each subscribed client.
If you write a custom publish that manages its own set and unset, you can use flush to push all pending changes down to the client. You'll find an example of that technique here: How does the messages-count example in Meteor docs work?

Resources