How do I get VSTS to build each branch into it's own drop folder - azure-devops

I would like to setup my pipeline in release management to use drops from Dev branch and UAT to use drops from master branch but not sure how to set this up as it seems they both write to the one location'drop'

Refer to these steps below:
Click +Add to add artifacts
Choose Git source type
Specify repository and branch and change Source alias to {repository name}-{branch}
Repeat 1-3 to add another branch

Related

Branches order in branch/tag selector for pipeline in Azure DevOps

We have repo in Azure DevOps with main and dev branches.
Previously, main branch was the only one branch. Then we have added dev, and set it as default repository branch.
But still, when I run pipeline, drop-down list with branches shows main as the selected pipeline. When I click on list, dev branch is on the first place, but anyway main is selected by default, so I have to select dev manually all the time.
Is there a way to change order/set default branch for that drop-down list? So when developer runs pipeline manually, there will be default repository branch selected (which is dev in our case). I have made some investigation, but could not find the answer...
Note, that setting branches in triggers parameters in yaml file does not do the trick. It does not influence on branches order in that drop-down list.
Click on the three dots in the YAML editor, & click on triggers:
Click on YAML tab & select the branch dev from the dropdown under Default branch for manual and selected builds
Do remember to save the changes.
As far as the order of branches is concerned, there isn't a way to change the order but you can favorite the branches by clicking on the star in front of branch name.
Hope this helps :)

How to get my branch as default in Azure Devops pipeline

When I go to run the pipeline it is bringing Master as default how to make it automatically grab my desired branch?
I want it to come loaded with the feat-regression-test branch:
https://learn.microsoft.com/en-US/azure/devops/repos/git/change-default-branch?view=azure-devops#set-a-new-default-branch
1 Under your project repo, select Branches.
2 On the Branches page, select More options next to the new default branch you want, and choose Set as default branch.

Cherry pick or selective merge from dev branch to prod

I have deployed Azure Data Factory pipelines and associated components to adf_publish branch in Azure Devops. Now I want to deploy those changes to the Prod branch, but the problem is that the Prod branch and adf_publish are not in sync. When I try to create a pull request I get 100 files and 100+ commits will be merged message which is not what I want. I want to merge only 1 Data Factory pipeline which was newly created and associated datasets (8) and Linked Service(1).
I tried the cherry pick method from the adf_publish branch but it still takes everything that is missing from Prod Branch. Is there an easy way to accomplish this either through the Azure Devops UI or through Visual Studio Code.
As per the screenshot below I see + next to multiple pipelines which indicates that they are not present in Prod branch, I just want to merge 1 pipeline and leave all the rest in adf_publish.
Any help would be highly appreciated. I have tried multiple things but nothing is working. Thanks
ADF_Publish branch will generate ARM templates for deployment automatically. Those templates you will be selecting as part of your release pipeline to perform deployment.
So, after merging ARM templates from ADF_Publish branch to another branch, if you are using same ARM template files from another branch to release deployment then it should work.
If the change(s) you seek aren't in separate commits, break the commit into individual commits using the approach outlined here. You use git rebase -i to obtain the original commit to modify, then git reset HEAD to selectively rollback changes, and finally git commit to commit that part as a new commit in the history.
Another useful technique is described in Red Hat Magazine, where they use git add —patch or maybe git add —interactive to add just sections of a hunk if you wish to separate various changes to specific files (search in that page for "split").
After splitting the modifications, you may now pick and choose which ones you wish.

Is it possible to set source dynamically in Azure Repos Git?

I'm looking for a solution to dynamically select a branch to build in the Azure pipeline. I have Azure Repos Git where I select project, repository and default branch. I would like to be able to select branch based on a variable.
What I'm trying now is to use the Command Line task and fire a git checkout command (e.g. branch is a variable):
git checkout $(branch)
I can't confirm it working yet but still I confirm it works but I feel that there is a better option than checking out default branch and then switching branch with the command line.
Update:
If you want to have single pipeline that can build different branches (version branches) for different branches, you could just specify them in the trigger of branch filters. This will not build all branches.
The branch you select in build definition is just the default branch used when you Queue New Build manually. OTOH the build trigger establish which branch to download, e.g. if the build has been triggered by a git push on branch develop then that is the one checkout'ed and built. Take a look at this link: Get the sources from the branch that triggered the build in Team Services
Besides, you could disable the default get source step.Then use you own powershell script and git command to get source code manually(just what you want) and check out branch, finally build based on your variable.
For YAML, to disable the default "Get Sources" just specify none in
the checkout:
checkout: none
For UI, please refer my reply in this question:
Is it able to ignore/disable the first step Get source in vNext Build?
Assuming you're choosing the default branch. That doesn't mean that
it's the only branch that can be built by that build definition.
You can choose which branches to monitor for CI (on the Triggers tab,
you can add multiple branch filters to represent the branches you wish
to build on commit), and the appropriate branch will be checked out
when the build is triggered. You can also choose an alternate branch
when manually queuing the build.
Source Link: Get Sources from multiple branches
If you want to dynamically select default branch as below, this is not available at present.
This is the branch that you want to be the default when you manually
queue this build. If you set a scheduled trigger for the build, this
is the branch from which your build will get the latest sources.
The default branch has no bearing when the build is triggered
through continuous integration (CI). Usually you'll set this to be
the same as the default branch of the repository (for example,
"master").
There is a related user voice here: When triggering a build, use the same branch as the trigger build. You could kindly vote up and track the process.

Passing parameters from github to Jenkins on push

We use an internally hosted github server for our SCM, Jenkins for our CI and Git-Flow (via maven's jgitflow plugin) for our branching strategy.
I have a Jenkins build job set up such that it takes the git branch as a parameter and then can check-out and build the correct branch based on what was selected.
.....
.....
.....
What I would like - is to automatically trigger the BASE_JOB to build only the branch that's been pushed. So far, I have been unable to find any way to do this.
If I set up to build when changes are pushed to github, then the job will simply rebuild whatever the last built branch was regardless of the branch that's been pushed.
I've seen some plugins for Jenkins that will auto-generate template jobs when new branches are created - but I think it is over-kill to necessitate having a job per currently active branch.
Is there a way to pass a branch parameter to the "Build when a change is pushed to GitHub"? Or some other way to work around this apparent limitation?
Thanks!
Check with these settings and see if it works.