is there a way how to listen DevOps repo events about repo creation.
Idea is to automate pipeline creation right after when a repo is created and it has a pipeline directory.
DevOps doesn't have such a built-in method to achieve your requirements:
https://learn.microsoft.com/en-us/azure/devops/service-hooks/events?view=azure-devops
But you can do something like this:
1, Create a time trigger azure function to capture all of the repo in your project.
2, Compare the current repos and previous repos each time with the last.
3, Create pipeline when you found the new repo created.
Related
Good morning,
I would like create a new branch from devel to create the branch of production, only using a task in azure devops, is it possible? I'm searching in marketplace if exists any good option.
Thanks for the help!
If you mean just to add some pipeline task, no. But you may consider using of:
Git commands: Run Git commands in a script.
Rest API: Create/Update/Delete a ref by repositoryId, Get started sample
AZ commands: az repos ref create
I have a Github and Azure Devops classic editor pipeline. I want to configure an auto-trigger of Azure pipeline after a commit happened in Github (If any commit happens in the repository, it needs to trigger my Azure Devops pipeline)
I tried configuring Continuous Integration in pipeline level, and it does not trigger my pipeline after a Github commit.
Many documents are for yaml pipeline but we need for classic editor pipeline. Could someone provide your inputs on how can we achieve the same ? Thanks!
You are looking for CI/CD triggers, you can simply choose the proper branch in the build trigger combo box.
"In the classic editor, pipeline triggers are called build completion triggers. You can select any other build in the same project to be the triggering pipeline.
After you add a build completion trigger, select the triggering build. If the triggering build is sourced from a Git repo, you can also specify branch filters. If you want to use wildcard characters, then type the branch specification (for example, features/modules/*) and then press Enter."
Source: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/pipeline-triggers-classic?view=azure-devops
if you are looking for deployment triggers you can find more info here:
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/triggers?view=azure-devops
release trigger snapshot
The configuration of #Bayoudhi Bilel is correct, after you select the Github as resource for Class editor pipeline, enable CI trigger in "Triggers" tab. (official doc here)
Check on my side, it works fine:
If your setting doesn't work, please firstly check if you have select correct branch to monitor. If it's correct, you can follow below steps to reconnect between azure devops and github repo.
Delete all webhooks on github repo setting.
Then edit your pipeline, go to "Triggers" tab, "restore" the webhook.
change to a new service connection(it's recommended to regenerate the github PAT, you can simply add all scope):
In my Azure devops, i did it by going to pipeline > Triggers tab and i activated "Enable continous integration". You can also configure the branches you want to build from.
It worked for me this way.
Please find screenshot attached.
I checked several sources, seems possible, but can't get it work.
What I want is that whenever a PR is created and PR build is successful, then a PR release is run and a site is created (either with PR Id or PR source branch, e.g. pr122--xxx.azuresite.net).
From an answer for this question,
Looks like I could use release.artifacts.alias.PULLREQUEST.ID, but when I tried it, this doesn't work at all. Also from the official doc, there is no mention of this variable. Is this only for the new YAML pipeline?
As most of our things are in classic pipeline, the solution I can think of is to parse the build source, which is refs/pull/11201/merge. Looks like 11201 is the Pull Request ID, so I just need to replace refs, pull,merge and "/". But I am not sure if better approaches available.
Following this doc: Deploy pull request Artifacts with Azure Pipelines, we can successfully create a pull request deployment by choosing Azure Repos as the source artifact.
If one pull request is created, a new release will be triggered. And as you have found, the source branch of build source is "refs/pull/{PullRequestId}/merge", so you are right.
In addition, if you set the Azure Repos as the primary artifact, we can get the pull request branch by using the predefined variable Release.Artifacts.{alias}.SourceBranch. In below example, we can use the PowerShell task to run below command.
Write-Host "Release.Artifacts._215.SourceBranch: $(Release.Artifacts._215.SourceBranch)
See: Default variables - General Artifact for details.
Apparently someone was using another repo in Azure DevOps to build a repo in GitHub.
He no longer works here and I have to change this. I do a Pull Request and it builds on another repo. But it does build in the correct repo once I merge the code to master.
The reason I need to change it is that it looks like its building from a YAML that is old and not sure which one.
How do I change where GitHub checks build for a PR? Is it only by removing the build in that other repo?
You could find required Azure DevOps pipeline in GitHub - Repo -Settings - Branches-Branches protection rule - Require status checks to pass before merging
According to the pipeline name, you could find corresponding YAML file in Azure DevOps Project - Repo. Check if this pipeline locates at the wrong repo of Azure DevOps side.
You could directly change the right pipelines if they are listed in GitHub side. Otherwise, you may have to reconfigure GitHub-Azure DevOps Service connection through Azure Pipeline extension.
I have four environments that I deploy to.
I also have four different code branches that we use to deploy code from.
We constantly switch the branches we use to deploy on these environments.
One time I want to build and deploy a daily branch on my test environment.
Later I want to build and deploy a enhancements branch on the same test environment.
Next I want to build and deploy the daily branch on my test2 environment.
I think you get the picture
We are currently using a manual process to pull from the branch we want deployed, then zip it up and push it to AWS code deploy.
Using Azure DevOps pipeline and release what is the easiest method to allow me to switch to use different branchs on different environments.
I currently have a successful setup in Azure DevOps that performs a gradle build, creates the artifact and then lets me push it over to AWS CodeDeploy on one of my environments. I just can't seem to figure out a way to eastily swtich the branch without creating tons of Azure pipelines and releases.
Thanks all!
Where you manually trigger a build pipeline by clicking Queue or Run Pipeline, A new windows shown as below will be prompted which allows you to switch the branches.
If you want to automatically deploy different branch to different environment. You can push the build artifacts over to AWS CodeDeploy in a release pipeline and set the branch filters. Please refer to below steps:
1, set branch filter in the build pipeline as shown in below screenshot which will build the selected branched. Check here for more information about triggers.
2, create a release pipline to push build artifacts over to AWS CodeDeploy.
And Set the Artifact filters which will only allow the artifacts built from the specified branch to be deployed to this tage.
You could use a queue time variable to specify the branch name you would like to use on your build pipeline. You would need to:
Edit your build pipeline and create the variable on the "variables" tab. Make sure to mark the "Settable at queue time" check
variable creation
Update the source of your build pipeline, to specify the new variable under the "Default branch" option. It would look something like this:
pipeline source
RUN your pipeline. Before finally clicking on RUN, you will be able to specify the desire branch:
set variable value
Hope this works