Can a Self Hosted Agent be set as enabled at certain times? - azure-devops

In Azure DevOps, can an agent be set as enabled or disabled at certain times? This is with self-hosted agents. I know there is the toggle in the UI to turn agents on at off as in the screenshot below. But can the enable and disable be scheduled? I'd like to add a user's machine at the weekend for example to help speed up the tests that are run, but obviously we don't want it running tests while in use Monday to Friday.

There's no option to enable/disable agents by schedule. However, you can try to achieve a similar effect with this approach:
Author a new pipeline with a single agentless job. It can invoke the Azure DevOps REST API to change the status of the agent (enabled/disabled). You can find this answer useful as a starting point.
Define the scheduled trigger the way you'd like your agent to be enabled/disabled.

Related

ADF- Define dynamic triggers

I created a scheduled trigger which executes an ADF pipeline in our development environment.
The trigger runs at 4AM on a daily basis.
I now want to release this process into our test ADF environment but the trigger should kick of at 6AM on a daily basis.
I cant find a method of dynamically changing these values based on environment.
Has anyone come across a solution for this?
Changing trigger settings can be achieved by using ADF utils and custom parameters definitions file, I included an example in this post: https://www.mutazag.com/blog/code/tutorial/ADF-custom-paramaters/#changing-trigger-settings

How to invoke iteration API query in Azure DevOps Services

I am trying to invoke the Rest API below for getting list of work items which are mapping to a specific iteration.
https://learn.microsoft.com/en-us/rest/api/azure/devops/work/iterations/get%20iteration%20work%20items?view=azure-devops-rest-5.1
Ultimately I want to invoke this as part of the Approval step in my Release pipeline so that the approver can verify if all work items for a given iteration are in Completed state.
I have two questions:
I don't know how to get the values for {team} and {iterationid}
How do I invoke this API as part of the approval gate. Should I use a Generic service connection? What user name and password do I need to provide?
Any working example here will be really helpful.
To get teams, you can use Teams - Get Teams on Team Project.
Then you can find all team iterations and their ids Iterations - List
You can use gates with azure function. Here is the example: Azure DevOps release gates with Azure Functions, PowerShell and VS Code
Additionally, you may consider to use quality gates with a work item query: Use approvals and gates to control your deployment

Is it possible to combine a gate and an approval to limit an Azure deployment?

In Azure, you can limit deployments with gates and approvals. Gates are usually some sort of status or health check. Approvals require a certain user or group to manually approve the deployment.
Is it possible to combine the two?
For example, I'd like for a deployment to require an approval but only if it's before 8 am or after 5 pm.
Another example would be to require an approval if the application is not live (liveness would be determined by a REST call).
No there is no way to create "conditional approvals" this way. You can schedule Gates and/or approvals but can't make one dependent on the other. The only thing you can configure is to ignore the gate and still ask for approvals or ask for approvals and then run the gates.
But what you can, using a custom release gate (Azure Function for example), is to do the required check and then use the Azure DevOps REST API to edit the release instance. An azure function with the right permissions could either enable or disable the approvers on the environment or override an approval.
An example of how to do this can be found here:
https://abelsquidhead.com/index.php/2017/12/25/creating-async-custom-automated-release-gates-in-vsts-with-rest-api/
https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/gates.md
https://github.com/Microsoft/azure-pipelines-extensions/tree/master/ServerTaskHelper/DistributedTask.ServerTask.Remote.Common

Getting "No more private agent slots available" attempting to add a new agent

From this link it appears that Agents have been renamed to Pipelines. https://www.visualstudio.com/en-us/docs/setup-admin/team-services/get-more-build-or-load-testing-vs
It also states that "Private agents are now free and unlimited." From Build & Release, Resource Limits, I show one free Pipeline.
We tried to add a second private agent to our VSTS and received the error:
"No more private agent slots available, please purchase more. For more information visit: https://go.microsoft.com/fwlink/?LinkID=623705 Current max: 1 Xaml Controllers: 0 Build Agents: 1"
From the link above it'd appear we did what we needed to do and should be able to add aditional agents. Any idea why we can't add an additional agent and Current max is 1?
Thanks for reporting this. It looks like there is a problem with the logic so the engineering feature team is going to deploy a fix that should fix this problem. You are right: you can have unlimited agents and concurrent pipelines is what we are transitioning to charging for where pipelines can leverage multiple agents if needed.
We have not switched from the agent-based model to pipeline model yet in Team Services. As we are still in the agent-based model, you will see this error if you have not purchased enough agents. We plan to switch to the pipeline model late January or early February.

Can Go (CI server) send mail for each failed build regardless of pipeline?

I'm using Go as my continuous integration server. I'm trying to get it to send an email if any stage in any pipeline breaks. So far, all I've found is a per-user email configuration, which forces me to add an email event per stage, per pipeline and per event. With 15 stages across 10 pipelines, and 3 events to trigger on, that's a lot of configuration.
Is it possible to configure it for all pipelines and all stages at once?
Post Go 14.3 you can add notifications for all pipelines and all stages at once. You would need to select the option similar to the one shown in the image below:
You could refer to the documentation for more details.