Customizing Git – Git Hooks

rajeshkumar created the topic: Customizing Git – Git Hooks
Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur. There are two groups of these hooks: client side and server side. The client-side hooks are for client operations such as committing and merging. The server-side hooks are for Git server operations such as receiving pushed commits. You can use these hooks for all sorts of reasons, and you’ll learn about a few of them here.

Installing a Hook

The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that’s .git/hooks. By default, Git populates this directory with a bunch of example scripts, many of which are useful by themselves; but they also document the input values of each script. All the examples are written as shell scripts, with some Perl thrown in, but any properly named executable scripts will work fine — you can write them in Ruby or Python or what have you. These example hook files end with .sample; you’ll need to rename them.

To enable a hook script, put a file in the hooks subdirectory of your Git directory that is named appropriately and is executable. From that point forward, it should be called. I’ll cover most of the major hook filenames here.

Client-Side Hooks

There are a lot of client-side hooks. This section splits them into committing-workflow hooks, e-mail-workflow scripts, and the rest of the client-side scripts
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

ERR! Error: failed to fetch from registry: gitlab-cli

rajeshkumar created the topic: ERR! Error: failed to fetch from registry: gitlab-cli
rajesh@mahto:~$ more /home/rajesh/npm-debug.log
info it worked if it ends with ok
verbose cli [ ‘/usr/bin/nodejs’,
verbose cli ‘/usr/bin/npm’,
verbose cli ‘install’,
verbose cli ‘gitlab-cli’,
verbose cli ‘-g’ ]
info using npm@1.1.4
info using node@v0.6.19
verbose config file /home/rajesh/.npmrc
verbose config file /usr/etc/npmrc
verbose config file /usr/share/npm/npmrc
silly exec /usr/bin/nodejs “/usr/share/npm/bin/npm-get-uid-gid.js” “nobody” 1000
silly spawning [ ‘/usr/bin/nodejs’,
silly spawning [ ‘/usr/share/npm/bin/npm-get-uid-gid.js’, ‘nobody’, 1000 ],
silly spawning null ]
silly output from getuid/gid {“uid”:65534,”gid”:1000}
silly output from getuid/gid
verbose cache add [ ‘gitlab-cli’, null ]
silly cache add: name, spec, args [ undefined, ‘gitlab-cli’, [ ‘gitlab-cli’, null ] ]
verbose parsed url { pathname: ‘gitlab-cli’,
verbose parsed url path: ‘gitlab-cli’,
verbose parsed url href: ‘gitlab-cli’ }
verbose addNamed [ ‘gitlab-cli’, ” ]
verbose addNamed [ null, ” ]
silly name, range, hasData [ ‘gitlab-cli’, ”, false ]
verbose raw, before any munging gitlab-cli
verbose url resolving [ ‘ registry.npmjs.org/ ‘, ‘./gitlab-cli’ ]
verbose url resolved registry.npmjs.org/gitlab-cli
http GET registry.npmjs.org/gitlab-cli
ERR! Error: failed to fetch from registry: gitlab-cli
ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
ERR! at Request. (/usr/lib/nodejs/request/main.js:212:58)
ERR! at Request.emit (events.js:88:20)
ERR! at ClientRequest. (/usr/lib/nodejs/request/main.js:412:12)
ERR! at ClientRequest.g (events.js:156:14)
ERR! at ClientRequest.emit (events.js:67:17)
ERR! at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
ERR! You may report this log at:
ERR! < bugs.debian.org/npm >
ERR! or use
ERR! reportbug –attach /home/rajesh/npm-debug.log npm
ERR!
ERR! System Linux 3.8.0-34-generic
ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “gitlab-cli” “-g”
ERR! cwd /home/rajesh
ERR! node -v v0.6.19
ERR! npm -v 1.1.4
ERR! message failed to fetch from registry: gitlab-cli
verbose exit [ 1, true ]
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

npm ERR! error installing node-gitlab@0.2.1

rajeshkumar created the topic: npm ERR! error installing node-gitlab@0.2.1
rajesh@mahto:~$ npm install node-gitlab
npm http GET registry.npmjs.org/node-gitlab
npm http 304 registry.npmjs.org/node-gitlab
npm http GET registry.npmjs.org/debug
npm http GET registry.npmjs.org/restful-client
npm http 304 registry.npmjs.org/restful-client
npm ERR! error installing node-gitlab@0.2.1

npm ERR! Error: No compatible version found: restful-client@’>=0.1.0- <0.2.0-' npm ERR! No valid targets found. npm ERR! Perhaps not compatible with your version of node? npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:488:10) npm ERR! at next_ (/usr/share/npm/lib/cache.js:438:17) npm ERR! at next (/usr/share/npm/lib/cache.js:415:44) npm ERR! at /usr/share/npm/lib/cache.js:408:5 npm ERR! at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7) npm ERR! at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7) npm ERR! You may report this log at: npm ERR! < bugs.debian.org/npm >
npm ERR! or use
npm ERR! reportbug –attach /home/rajesh/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.8.0-34-generic
npm ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “node-gitlab”
npm ERR! cwd /home/rajesh
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: restful-client@’>=0.1.0- <0.2.0-' npm ERR! message No valid targets found. npm ERR! message Perhaps not compatible with your version of node? npm ERR! Error: EACCES, open 'npm-debug.log' npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! npm ERR! System Linux 3.8.0-34-generic npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "node-gitlab" npm ERR! cwd /home/rajesh npm ERR! node -v v0.6.19 npm ERR! npm -v 1.1.4 npm ERR! path npm-debug.log npm ERR! code EACCES npm ERR! message EACCES, open 'npm-debug.log' npm ERR! errno {} npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/rajesh/npm-debug.log npm not ok rajesh@mahto:~$ npm -v 1.1.4 rajesh@mahto:~$ node -v The program 'node' can be found in the following packages: * node * nodejs-legacy Try: sudo apt-get install
rajesh@mahto:~$ sudo apt-get install node
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

My Gitlab First Notes…

rajeshkumar created the topic: My Gitlab First Notes…
To work in gitlab, login as a scmadmin
su – s ( go to root)
su – git 9 go to as a git user)

To see the config –
cd /home/git/gitlab/config
more gitlab.yml
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u

rajeshkumar created the topic: FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u
FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Error

gitlab-ctl reconfigure
Starting Chef Client, version 11.12.2
Compiling Cookbooks...
Recipe: gitlab::default
* directory[/etc/gitlab] action create (up to date)

================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb
================================================================================

RuntimeError
------------
External URL must include a FQDN

Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:95:in `parse_external_url'
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:191:in `generate_config'
/opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:34:in `from_file'

Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:

88:
89: def parse_external_url
90: return unless external_url
91:
92: uri = URI(external_url.to_s)
93:
94: unless uri.host
95>> raise "External URL must include a FQDN"
96: end
97: Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
98: Gitlab['gitlab_rails']['gitlab_host'] = uri.host
99: Gitlab['gitlab_rails']['gitlab_email_from'] ||= "gitlab@#{uri.host}"
100:
101: case uri.scheme
102: when "http"
103: Gitlab['gitlab_rails']['gitlab_https'] = false
104: when "https"

Running handlers:
[2014-11-03T12:38:40+05:30] ERROR: Running exception handlers
Running handlers complete

[2014-11-03T12:38:40+05:30] ERROR: Exception handlers complete
[2014-11-03T12:38:40+05:30] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.925307977 seconds
[2014-11-03T12:38:40+05:30] ERROR: External URL must include a FQDN
[2014-11-03T12:38:41+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

more /etc/gitlab/gitlab.rb
# Check and change the external_url to the address your users will type in their browser
external_url ‘hostname:9999’
unicorn = 9090

Log file

Dumped to
/opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out

OS
RHEL 6.5
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u
Solved after
hostname.dev.corp.local:9999
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u
I am still not able to access the gitlab url from browsers…with following info….
gitlab-ctl show-config
Starting Chef Client, version 11.12.2
Compiling Cookbooks…
{
“gitlab”: {
“bootstrap”: {

},
“user”: {

},
“redis”: {

},
“gitlab-rails”: {
“secret_token”: “f276844818b47932ab27c670536111f68d4ad8d84e3d02a42a0f8be23e00c78a0094f62efbd08655f3430a9524258f39b82281e10d52c391c2e751f5747d45dc”
},
“gitlab-shell”: {

},
“unicorn”: {
“port”: 9090
},
“sidekiq”: {

},
“nginx”: {

},
“logging”: {

},
“remote-syslog”: {

},
“logrotate”: {

},
“high-availability”: {

},
“postgresql”: {

},
“web-server”: {

}
}
}
Converging 0 resources

Running handlers:
Running handlers complete

Chef Client finished, 0/0 resources updated in 10.57749914 seconds

gitlab-ctl status
run: logrotate: (pid 19510) 136s; run: log: (pid 10239) 4278s
run: nginx: (pid 20043) 2s; run: log: (pid 9765) 4365s
run: postgresql: (pid 19516) 135s; run: log: (pid 9569) 4393s
run: redis: (pid 19524) 135s; run: log: (pid 9432) 4475s
run: sidekiq: (pid 19529) 134s; run: log: (pid 9712) 4371s
run: unicorn: (pid 19534) 134s; run: log: (pid 9664) 4377s

more /etc/gitlab/gitlab.rb
external_url = ‘xysudyd.dev.corp.local:9999’
unicorn = 9090
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

If you have forgotton the admin password of Stash

rajeshkumar created the topic: If you have forgotton the admin password of Stash
If you have forgotton the admin password of Stash.

1. Edit the \bin\setenv.sh file (or setenv.bat on Windows) and add the “-Datlassian.recovery.password=temporarypassword” argument to the JVM_SUPPORT_RECOMMENDED_ARGS property. The property value must be non-blank,Here we are using “temporarypassword”, but you can use your own value.

2. Start Stash.
3. Log in to Stash using the ‘recovery_admin’ username and the temporary password specified in Step 1.
4. Repair your Stash configuration.You may reset the admin password as well. We strongly recommend that you do not perform other actions while Stash is in recovery mode.
5. Confirm your ability to log in with your usual admin profile.
6. Shut down Stash, remove the atlassian.recovery.password argument from setenv.sh, and restart Stash as usual.

Reference- confluence.atlassian.com/display/STASH/Lockout+recovery+process
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Couldn’t find host github.com in the _netrc file; using defaults

rajeshkumar created the topic: Couldn’t find host github.com in the _netrc file; using defaults
C:\Build_WS\BuildDeployment\Job1\117>git push –verbose

* Couldn’t find host github.com in the _netrc file; using defaults

* Adding handle: conn: 0xc7d838

* Adding handle: send: 0

* Adding handle: recv: 0

* Curl_addHandleToPipeline: length: 1

* – Conn 0 (0xc7d838) send_pipe: 1, recv_pipe: 0

* About to connect() to github.com port 443 (#0)

* Trying 192.30.252.130…

* Connected to github.com (192.30.252.130) port 443 (#0)

* successfully set certificate verify locations:

* CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt

CApath: none

* SSL connection using AES128-SHA

* Server certificate:

* subject: businessCategory=Private Organization;

1.3.6.1.4.1.311.60.2.1.3=US; 1.3.6.1.4.1.311.60.2.1.2=Delaware;

serialNumber=5157550; street=548 4th Street; postalCode=94107; C=US;

ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com

* start date: 2014-04-08 00:00:00 GMT

* expire date: 2016-04-12 12:00:00 GMT

* subjectAltName: github.com matched

* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert

SHA2 Extended Validation Server CA

* SSL certificate verify ok.

> GET /EigenRisk/RACE/info/refs?service=git-receive-pack HTTP/1.1

User-Agent: git/1.9.5.msysgit.0

Host: github.com

Accept: */*

Accept-Encoding: gzip

Pragma: no-cache

< HTTP/1.1 401 Authorization Required * Server GitHub Babel 2.0 is not blacklisted < Server: GitHub Babel 2.0 < Content-Type: text/plain < WWW-Authenticate: Basic realm="GitHub" < Connection: close < * Closing connection 0 Build was aborted Aborted by anonymous Finished: ABORTED Regards, Rajesh Kumar Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Couldn’t find host github.com in the _netrc file; using defaults
Solution:
Add following line…
git config http.postBuffer 524288000
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

ERROR: Error cloning remote repo ‘origin’

rajeshkumar created the topic: ERROR: Error cloning remote repo ‘origin’
Error
Started by user anonymous
Building in workspace D:\tools\jenkins\jobs\Matrix-Fast-java\workspace
Cloning the remote Git repository
Cloning repository github.com/scmgalaxy/helloworld-java-ant.git
> git.exe init D:\tools\jenkins\jobs\Matrix-Fast-java\workspace # timeout=10
ERROR: Error cloning remote repo ‘origin’
ERROR: Error cloning remote repo ‘origin’
Finished: FAILURE
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: ERROR: Error cloning remote repo ‘origin’
Solution 1: check if git is installed or not. Also git should be set in PATH
Solution 2: Go to http://localhost:8080/configure and Set the correct git executable path
see attached image as well….

How to Install git in Ubantu?
sudo apt-get install git

How to Install git in CentOS
yum install git

How to Install git in CentOS
git-scm.com/download/win && Set git executables in PATH
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: ERROR: Error cloning remote repo ‘origin’
You can also install git automatically by selecting the checkbox as shown in pic

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

After Pushing tag in Gitlab UI, Gitlab should fire jenkins job.

ghanshyamjisingh@gmail.com created the topic: After Pushing tag in Gitlab UI, Gitlab should fire jenkins job.
Requirement: After Pushing tag in Gitlab UI, Gitlab should fire jenkins job.

My setup:
I am using wehooks to to this configuration, the configuration is all fine.

Issue: when I push tag through Git Bash, it is triggering jenkins job, but when i push though Gitlab UI it does not.

Attach is my setup.

Also I dnt want to use Gitlab plunging to trigger jenkins job.

Tagged :

Protocol error: bad band #101?

scmuser created the topic: send-pack: protocol error: bad band #101?
How to resolve this issue during push in git using jenkins….
21:36:30 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.1-snc1:prepare (default-cli) on project wmi: Unable to tag SCM
21:36:30 [ERROR] Provider message:
21:36:30 [ERROR] The git-push command failed.
21:36:30 [ERROR] Command output:
21:36:30 [ERROR] send-pack: protocol error: bad band #101
21:36:30 [ERROR] fatal: The remote end hung up unexpectedly
21:36:30 [ERROR] fatal: The remote end hung up unexpectedly
21:36:30 [ERROR] -> [Help 1]
21:36:30 [ERROR]
21:36:30 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
21:36:30 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
21:36:30 [ERROR]
21:36:30 [ERROR] For more information about the errors and possible solutions, please read the following articles:
21:36:30 [ERROR] [Help 1] cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Tagged :