How to trigger perforce changes before the submit using TeamCity - continuous-integration

I have currently CI system which triggers submit and particular stream and then builds the change and tests it.
However as I said it is done upon submit, meaning the change is merged before the testing.
So my question is how I can trigger the changes in an earlier stage? What is the best approach?
We are not using any IDEs for development.
Thanks!

To do it on the Perforce side, you'd use a change-content trigger, which runs prior to submit while the files are available in a staging area on the server (the in-flight change is treated as a shelf and can be accessed using the #=change syntax). This allows a trigger script to access the content in-flight and reject it before it's finalized.
While a content trigger is running, the files are locked, and the submit will block the client session until it's finalized on the server and can report success, so you'd want to be careful about which codelines you enable something like this on.

Related

Git extra hook, pre-upload

I'm a university student. Currently, I’m doing my Final Year Project that requires a hook that executes automatically on the server side of the repository, before the objects been pulled to the client side, and after the objects have been pushed to the server side, which is "post-receive" hook.
I have done lots of research regard on the hook and I came to know grack and rjgit_grack. Links will be attached below.
Grack : https://github.com/grackorg/grack
Rjgit_grack : https://github.com/grackorg/rjgit_grack
Grack and rjgit_grack is a gem from https://rubygems.org/. Grack project aims to replace the builtin git-http-backend CGI handler distributed with C Git with a Rack application and rjgit_grack is an alternative adapter of grack that support extra hooks for git that have the hook that I needed for my project, "preUpload" hook that is executed immediately before an upload-operation is performed, i.e. before data is sent to the client. But I was unable to get it to work for my project due to various reasons.
Why Git doesn't have a hook that executed immediately before the data is sent to the client? Any advice on getting this hook or any similar function of the hook?
The idea behind Git hooks is that they do at least one of two things: change the state of the repository or the current operation, or optionally block a behavior from occurring.
A hook that executes before objects are pushed wouldn't be able to do either one of these: it has no data about how to change the repository, since it doesn't have any objects, and without any data about what's going on, there's no way that it can usefully determine whether to block a push.
For your project, it might be useful to wrap the git HTTP backend script with a wrapper that executes before the push service starts, or one that looks for the flush pkt-line delimiter (0000) by intercepting the data. You could also patch Git to have the hook you need for your project at the appropriate location.

How to cancel/abort an XCode Bot Integration in Before Integration Script

I have a bot working on commit and it increases the build number and pushes to the same branch. I check the commit's user in Before integration script, and if it is the CI user (which is only and only used to push the increase number commits) i want to abort current integration. I saw this one:
https://stackoverflow.com/a/30062418/767329
/xcode/api/integrations/INTEGRATION_ID/cancel
This one makes a curl call to stop the integration but i want to stop the current integration before it starts. I know i may also check and push the increase commit if the bot is not run by ci user's increase commit lately. But i dont want even archive to work if it is a ci user commit (i want the integration to be aborted even before it starts).
Unfortunately there is no way to cancel an integration before it even starts. You could use a pre-integration trigger to stop the integration from going further given whatever conditions you are looking for.
If your only goal is to bump the build number, I would suggest you use the Xcode Server environment variable 'XCS_INTEGRATION_NUMBER' in your build number field.
Whenever Xcode Server integrates your project, it will automatically use the integration number as the build number. These will always be unique.

how to auto open an entity created in a workflow

I have run into a situation where I need to open a newly created quote at the end of a workflow. I have a feeling this is going to require me to create a a very simple custom workflow that uses "window.open", but I would like to avoid this if anyone has a better idea.
So I need to open a newly created quote as soon as it is created in a workflow. Anyone have any good ideas on how to do this?
Workflows are asynchronous; they run on the server (as opposed to the client) and do not run in realtime. eg a workflow that is triggered by creation of a record will run on the server sometime after the record is created (depending on system load etc - it could be a second or two, or could be half an hour later. If you have stopped the CRM Async service on the server, they might well never run.)
Because they run on the server the user has no interaction with them. As a result you can't open a window, as there's no user involved to open a window for...
What you probably want to do is make use of Dialogs (introduced in CRM 2011). You won't be able to use window.open() but as long as you've got a recent update rollup installed on the server you can present the user with a hyperlink to most CRM records.
Setup of Dialogs is much the same as Workflows, and they use the same mechanics under the hood. The difference is that they're syncronous (i.e. run in real-time) and they are client-side. There's some detail on Technet: http://technet.microsoft.com/en-us/library/gg334463.aspx

Update form throw an plug-in crm 4

I try to update an entity with a plugin. I use Image (pre) and stage Post with asynk... The databse is updated in real time, but not the form. Does anybody know why i have to "upate" two times to se the updated text in the webform and the value is updated in the database immediately? I want to se it "immediately". Thanks
With asynchronous plugin execution, the database is never really updated "in real time"; the asynchronous execution might just happen so quickly that it looks that way to a human's "slow" perception.
On a server process level, however, the code of an asynchronous plugin will run "when there is time", while the code that rebuilds the form and sends it back to the client is running "immediately" and will wait for synchronous plugins, but not for asynchronous ones.
If you want the changes your plugin makes to be reflected in the entity form immediately after the reload, the plugin has to be registered for synchronous execution.
As far as I know, for asynchronous plugins, as well as for workflows, there is no timeframe in which they are guaranteed to run after being triggered.

How to get notification of workflow errors?

I am having issues were a workflow is stalled because there is an issue with sending an email (send email activity). Typically, this is simply solved by resuming the workflow. I'm wondering if there any way to react to a workflow error, so the user knows they need to go in and resume the workflow.
I'm also wondering about this relative to a workflow that is attempting to assign a task to a user who no longer exists in the CRM or one that has an invalid email address, which I'm assuming would cause errors in workflows as well.
Any other suggestions related to this sort if issue would be welcome.
Thanks!
My point of view, is that monitoring can't be done inside CRM, because all CRM processes could be problematic (what happen if a workflow fails to monitor another workflow?)
The way I already done that, was by adding a SQL query (that check the workflow instance state) to a monitoring tool (such as Nagios with the check_mssql_health) or you can just create a small service that will send emails using SMTP.
Off the top of my head, I can't think of an automated way to do it (you could try attaching a workflow to a workflow instance record, but I'm not sure if that will do it).
I'd probably try to build a utility to query workflow instance records, and then notify users if necessary based on their status.

Resources