Azure pipeline on PR validate file before merging to master branch - azure

I have master branch which has multiple yaml files. Every file on update will be pushed to feature/{filename.yaml} and with PR will be merged to master branch.
But before merging I need to validate that file from feature has valid YAML syntax.
If syntax is not valid build will fail and not be merged to master branch.
But if everything is ok I need to send content of yaml file to API endpoint, and then merge it to master branch.
Thanks

You can use Files Validator task to validate file.
[

Related

Why is the default branch selected as default value on Files and create merge request?

In the GitLab in Files, create a branch or create a merge request I see the default branch was selected. What use of given this branch as default value.
While the default target branch is, by... default, the default branch of the repository, don't forget that, starting GitLab 13.11 (April 2021), you can set another branch as the default target for merge request.
That way, you can setup merge request which would target your own fork instead of upstream, if that is what you need.
In both cases, the use is to establish a default target branch for your MR.
When a merge request uses an issue closing pattern to close an issue, the work is merged into this branch.

how to pass git commit message from parent to child pipeline in gitlab?

I have a commit message stored in /tmp/message file in parent's pipeline and I would like to send the contents of this file to the child pipeline in Gitlab. Can someone help me how I can do this using yml pipelines?
One approach is to use a cache (as seen here), or rather an artifact (as seen here), in order to store that message content in a file.
The idea is to share a file (artifact) or key/value (cache) between jobs.

Gitlab - run script after create branch

Is there any option to execute script after branch command: 'git branch new123? If user will create new branch I would like to auto checkout into new branch and auto create folder 'new123' with branch name and two other folder inside this folder like 'int', 'ext'.
You would need:
either a GitLab webhook, that is a listener on a server you control, which would receive JSON push events from GitLab, and, when detecting a new branch, would perform the operations you describe in a local clone of the repository.
or a GitLab-CI job which can run on every push, and whose job would check if that push is a new branch, before doing the same operation in its workspace (so on GitLab side rather than on a private server like a webhook does)

Azure REST API Get Branches returning 0 branches

I am trying to get all branches for a project with
https://dev.azure.com/$organization/$project/_apis/tfvc/branches?&api-
version=5.0
I use the credentials, organization, and project variables in other queries that are working. The request format is based off the example here
https://learn.microsoft.com/en-us/rest/api/azure/devops/tfvc/branches/get?view=azure-devops-rest-5.0
The response I am getting is
count value
----- -----
0 {}
when there are many branches in the repository.
Should I be specifying the repository somewhere? Or what else? Thanks!
First you need to confirm which type of repository you need to use rest API to get branch from, git or tfvc.
If you want to get branches from a tfvc repo, then use the rest api as you refer to in your case.
But, you need to be aware that if the count you want to return is not 0, you should ensure that there are branches in your tfvc repo, not just folders and files.
To convert the folder in tfvc repo to branch, you can convert it in vs source control explorer. For details, please refer to this docs.
If you want to get branches from a git repo, you need to use the rest API as follows.
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=5.0

Is it possible to block merge request that have commit behind in gitlab?

In gitlab, I'd like to block merge request when the requested branch has some commit behind. So that the requester have to merge/rebase again (+ test)
Is it possible to configure gitlab to enforce that?
This feature exist but only in the entreprise edition:
https://docs.gitlab.com/ee/user/project/merge_requests/fast_forward_merge.html
To achieve this, set the merge method to Fast-forward merge: gitlab won't create merge commit and thus the branch to merge should contain all commit of the destination branch

Resources