Gitlab pre-commit hook - hook

I would like to use pre-commit hook in gitlab. I doing everything like in documentation: https://docs.gitlab.com/ce/administration/custom_hooks.html
In custom_hooks directory I've created pre-commit file with folowing content:
#!/bin/bash
exit 1
Hook is never triggered, couse i can commit.
When i do the same with pre-receive hook - everything works good.
If Gitlab doesnt't let to use pre-commit hook?

As explained in Customizing Git - Git Hooks, a client-side hook won't be used on the server.
I explained before why it is not possible to include hooks in a clone:
"why it is not possible to git add .git/hooks/my-hook"
"Any way to put my hook to github repo?"
Since GitLab 7.5, you can set custom Git Hooks for server-side hooks.
Git natively supports hooks that are executed on different actions. Examples of server-side git hooks include pre-receive, post-receive, and update
Normally, Git hooks are placed in the repository or project's hooks directory. GitLab creates a symlink from each project's hooks directory to the gitlab-shell hooks directory for ease of maintenance between gitlab-shell upgrades

Related

How do I prevent JHipster from automatically committing to my Git repo?

When I run jhipster import-jdl, it automatically commits to my Git repository. Is there a way to prevent this?
Use --skip-git option
See doc: https://www.jhipster.tech/creating-an-app/#3

Changes not showing up in NodeJs/ReactJs apllication running on Heroku?

I have made changes to some css and js file in my Node-React apllication which is deployed on Heroku. But the changes are not showing up when I git add . the project on heroku. ALthough the changes are not coming up when I run the project locally.
Any help would be appreciated on what could be the possible cause on the changes not getting deployed?
You need a few more commands in your deployment workflow.
The git add . command is putting your local changes into staging.
You also need to run git commit -m 'your commit message' in order to commit those local changes to your local git repository.
Next, you need to run git push to push your local repository to the remote repository it is linked with.
Effective use of git is one of the most useful things you can teach yourself as a developer. It will enable you to contribute effectively to a team when the time comes. Here's a good starter article: Basic Git With Examples.

How to disable any optional feature in jhipster?

How to disable any optional feature in jhipster such as "Kafka" rather than regenerating another Jhipster app from scratch?
Edit the .yo-rc.json file in your project, commit it, delete src folder and run jhipster --with-entities.
Of course, if you already have added custom code, you may want to do this in a git branch and use adequate git merging strategy like git merge -s recursive -Xours <branch name> to keep your changes

`git clone project2` in gitlab-ci.yml?

I'd like Gitlab CI to fetch source code of another project. Is there a better way than adding a read-only deploy key and setting it up in .gitlab-ci.yml?
You can also use GIT SUBMODULES within your project A to refer to project B and then add
GIT_SUBMODULE_STRATEGY: recursive
to the gitlab-ci.yml file in project A.
This also enables you to specifically include a specific branch or commit from your subproject.
https://docs.gitlab.com/ce/ci/git_submodules.html

How to use remote paths in gitlab ci?

I installed GithubHQ in one server and GitlabCI in another server. But now I need do integration between GitlabHQ and GitlabCI. When I go to add a new project in GitlabCI he requests a path .git project, but the project is on another server where the GitlabHQ.
I tried use the path remote, like: http://[domain-name]/[user]/[project].git but he not accept.
I researched about how GitlabCI search the path and found that it does not support remote paths. He use "Rugged::Repository.new(path)" just to get the project on the server.
Does anyone know a way to use paths .git remotes in GitlabCI?
As illustrated by Issue 36:
Actually the purpose of gitlab-ci implies that you install it on deployment point. You install it where you deploy your project
So you are supposed to use a local non-bare repo.
You could, in your case, clone your remote repo on the gitlab-ci server, and use that local path.
In order to build an integration between gitlab and gitlab-ci:
add gitlab_ci user to git group for read access
clone your project via git clone /home/git/repositories to somewhere like /home/gitlab_ci/projects/...
add this project to ci.
setup gitlabhq to use ci service
Thats all.
On gitlab push it will trigger gitlab ci to make git fetch origin, so testing repo will be always up to date.

Resources