Gitlab - run script after create branch - gitlab

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)

Related

Azure pipeline on PR validate file before merging to master branch

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.
[

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.

GitLab - Update private project dependent on public project

Assuming that there is a public project publicProject. And you have got your own private Project privateProject.
Is there a way to automatically trigger a CI/CD pipeline wihin privateProject every time publicProject receives a new push? Note, that although publicProject is public, there is no way to modify the pipeline within publicProject - so no trigger would be possible.
Are there any chances this could be possible?
If no trigger is possible, you might need, as a workaround, to schedule your own pipline (see "Configuring pipeline schedules") in order to:
pull the public repository
check if new commits have been done
The last fetched commit could be cached (see Caching in GitLab CI/CD) in a file which can persists between subsequent jobs.

Trigger a new pipeline on merge request creation in gitlab-ci

i have a mono repo structure and created a pipeline that only runs for specific sub folders which have changed.
Now if i change something in Context1 and the pipeline does not succeed, and then change something in Context2 and the pipeline succeeds, a created merge request would say it is mergeable because the last pipeline succeeded.
How can i trigger a new pipeline on a merge request that runs the pipeline that runs for all sub folders? (Not asking how to create such a pipeline, only how to trigger one)

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