PM2 with mercurial repo in deployment - deployment

I have a mercurial repository in bitbucket.org and I want to use it in deployment with pm2.
My deploy section is:
deploy : {
production : {
user : "dimon",
host : "app.mysite.com",
ref : "origin/master",
repo : "hg#bitbucket.org:mylogin/myrepo",
path : "/var/www/test_prod",
"post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production"
}
}
When I run deploy I get a error:
○ cloning hg#bitbucket.org:mylogin/myrepo
Cloning into '/var/www/test_prod/source'...
conq: not a git repository.
fatal: Could not read from remote repository.
I also tried "mercurial#bitbucket.org:mylogin/myrepo" string, without success.
How to set mercurial repository correct?

According to maintainers, pm2 deploy works only with git now.
GitHub

Related

Jenkins credentials for cloning a github repository via ssh when deploying

I have some problems getting jenkins to do a composer update, because one of the composer dependencies is a private git repo, hosted on Github
I am also having problems getting the composer update command to work in the commandline:
$ cd /var/lib/jenkins/jobs/JOB/workspace
$ ls -la auth.json
-rw-rw-r-- 1 jenkins jenkins 99 Aug 3 15:49 auth.json
$ cat auth.json
{
"github-oauth" : {
"github.com" : "<notAvailableOnSO>"
}
}
$ composer update -n
Error:
Failed to clone the git#github.com:<Org>/<Project>.git repository, try running in interactive mode so that you can enter your GitHub credentials
[RuntimeException]
Failed to execute git clone --mirror 'https://***:***#github.com/<Org>/<Project>.git' '/var/lib/jenkins/.composer/cache/vcs/git-github.com-<Org>-<Project>.git/'
Cloning into bare repository '/var/lib/jenkins/.composer/cache/vcs/git-github.com-<Org>-<Project>.git'...
remote: Repository not found.
fatal: repository 'https://***:***#github.com/<Org>/<Project>.git/' not found
The project that I'm trying to update has this repositories setting in it's composer.json:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/<Org>/<Project>.git"
}
]
Even without the -n (interactive mode), I can input the github oauth token and have composer report back that the token has been saved and still get the error.
Am I putting the auth.json in the wrong place, or should I do the authorisation differently?
(It is obviously not possible to publish proprietary source code on github for the sake of having a deployment work)
I got the "composer update" command to work (command line and via jenkins).
After actually reading the error message and understanding that the repository wasn't available for the user, logging into github, I solved my problem by ensuring that the github user actually was allowed read-access to the repository.
:)

bower - fatal: unable to connect to github.com

After upgrading ember-cli on my mac (Yosemite 10.10.2)
npm uninstall -g ember-cli
npm cache clean
bower cache clean
npm install -g ember-cli#0.1.12
....
or maybe after Yosemite upgrade to 10.10.2,
or after upgrade my Java to v8-32...
my bower doesnt work anymore.
If I try:
bower list
I get an error:
bower check-new Checking for new versions of the project dependencies..
bower ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/rwjblue/ember-cli-test-loader.git", exit code of #128
Additional error details:
fatal: unable to connect to github.com:
github.com[0: 192.30.252.128]: errno=Operation timed out
But if I execute:
git ls-remote --tags --heads git://github.com/rwjblue/ember-cli-test-loader.git
it works:
git ls-remote --tags --heads git://github.com/rwjblue/ember-cli-test-loader.git
c6006a11515c756d115bb5209103a22c2e9554a0 refs/heads/master
929777f8b5c60db3120712c7328f5debdf74a0cd refs/tags/0.0.1
055d50f770ad333e7ead10ecb04605f951e2435b refs/tags/0.0.2
9defa2c59df38dcc334d6c1cc266075c04c2a4f6 refs/tags/0.0.3
a925b8fc428829ea3599e66eb0e6353726426356 refs/tags/0.0.4
c6006a11515c756d115bb5209103a22c2e9554a0 refs/tags/v0.1.0
Also every git clone git:// or http:// works and I can access 192.30.252.128 over http.
Only in combination with bower it doesnt work.
With npm I have also no problems.
What Im trying was to uninstall and reinstall bower. But this doesnt solve the problem.
Next try:
.bowerrc
with:
{
"directory": "bower_components",
"analytics": false,
"proxy": "",
"https-proxy": ""
}
Next try:
.gitconfig
[url "https://"]
insteadOf = git://
With the result:
Additional error details:
fatal: unable to access 'https://github.com/furf/jquery-ui-touch-punch.git/': Failed to connect to github.com port 443: Operation timed out
Iam also try:
ssh -T git#github.com
to add github.com under known_hosts.
The strange thing is:
ssh -T git#github.com
ssh: connect to host github.com port 22: Operation timed out
Try it again:
ssh -T git#github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
So sometimes it works and sometimes not. A look at https://status.github.com/
shows that everything is fine from github.
But why I get sometimes a timeout?
Maybe a DNS Server lag? Every other connections are fine.
Also a ping is looking fine:
The badest time was
time=100.173 ms
over minutes and I start parallel the bower install command with same timeout as before.... but the ping was going on and only with 100ms.
Im also exit my firewalls with no result.
I have no proxy configurred.
Any idea?
Update 09/02/2014
Im currently in Hamburg and here, the bower install works fine. So it is not a problem of my system installation.
Update 12/02/2014
After being back at home, it also works without any changes.
Strange!
From this npm thread: https://github.com/npm/npm/issues/5257#issuecomment-60441477
Try dumping the following into your .gitconfig
[url "https://"]
insteadOf = git://
[url "https://github.com"]
insteadOf = git#github.com
Since I'm on a Windows machine, I also had to ensure that c:\users\me\.gitconfig and the one on my modified home drive h:\.gitconfig were the same.
Run
git config --global url."https://".insteadOf git://
saves lot of pain specially if one is behind the firewall.
One Solution for Requiring Modules
This solution has not been tested against bower list, however, (like in my situation) you may be impeded to bower installs due to local, environmental policies. Here's what allowed me to leverage Bower -- saving me from a multitude of headaches:
...
"dependencies": {
"angular": "https://code.angularjs.org/1.3.15/angular.js",
"jquery": "https://github.com/jquery/jquery.git#~2.1.4",
"moment": "https://github.com/moment/moment.git",
"underscore": "https://github.com/jashkenas/underscore.git#~1.8.3"
}
...
OR,
bower install https://domain.ext/path/to/asset.ext -S
You may be getting the error, fatal: unable to connect to github.com: while trying to install -- this is because in some environments bower cannot resolve the git:// protocol. However, it will resolve http(s):.
My suggestion:
Search Bower for a package,
Navigate to the git repository,
Copy the https git clone URI,
bower install https://.../author/module.git --save
This will save (--save / -S) the package to your bower.json file with the #~n.n.n notation for the package-version.
Hope this helps you guys as it did I.

How to get Jenkins checking out private vendor repo via composer

I've got a project that I wan to build with Jenkins.
The project is hosted in a private GitHub repo and I've put the SSH public key in GitHub of my user "deploy".
The project gets checked out fine thanks to the deploy credential in Jenkins git plugin section in the build config.
But a vendor lib which is hosted as private in same GitHub organisation is loaded via a build step command :
php composer.phar install -o --prefer-dist --no-dev
I've installed Jenkins git plugin in order to checkout the main repo from GitHub via private SSH key.
But when the composer tries to checkout the sub project I get
Failed to clone the git#github.com:Organisation/Repo.git repository, try running in interactive mode so that you can enter your GitHub credentials
I've tried to get the composer command ran as a different user without success with stuff like :
su - deploy -c 'php composer.phar install -o --prefer-dist --no-dev'
looks weird anyway. I'd like to figure out the proper way of having the composer doing his job. Thought ?
Jenkins is actually running the shell commands as "jenkins" user.
It means that "jenkins" needs access to GitHub.
Then all the git#github.com:Organisation/Repo.git will work without additional credentials.
Here is explained how to grant Jenkins access to GitHub over SSH
# Login as the jenkins user and specify shell explicity,
# since the default shell is /bin/false for most
# jenkins installations.
sudo su jenkins -s /bin/bash
ssh-keygen -t rsa -C "your_email#example.com"
# Copy ~/.ssh/id_rsa.pub into your Github
# Allow adding the SSH host key to your known_hosts
ssh -T git#github.com
# Exit from su
exit
Inspired from: Managing SSH keys within Jenkins for Git

Jenkins/Github: Apparently .git/config doesn't exist?

So after installing the Github plugin to Jenkins CI and attempting to add a job for my Github project to compile automatically after a Github push to master, Jenkins reports that .git/config doesn't exist.
I went to /var/lib/jenkins and created .git and the config file and chowned them to jenkins:nogroup.
The error persisted. I then went and did this in my own VPS home directory. Error persists.
I then made a home folder for the jenkins user with no shell and did the same steps. Error persists.
Which .git/config is it referring to?!
Edit:
The actual error I'm referring to is:
Failed to connect to repository : Command "git config --local credential.helper store --file=\"/tmp/git7406572387997126825.credentials\"" returned status code 255:
stdout:
stderr: error: could not lock config file .git/config: No such file or directory
Solved...switched to SSH.
Steps:
Assume control of Jenkins user. su jenkins
(You may need to set a password for it first (make it good!) sudo passwd jenkins.
Go home: cd ~.
Generate key: ssh keygen -t rsa -C "email". (No passcode)
Copy $JENKINS_HOME/.ssh/id_rsa.pub to Github.
Set Jenkins credentials to authenticate to Github using the private key.
Works fine.
Found a neat workaround here: https://groups.google.com/forum/#!topic/git-users/pyv6ldFxUio
mkdir ~/.git
git config --global user.email "m...#school.com"
https://groups.google.com/forum/#!topic/git-users/pyv6ldFxUio

Jenkins not building github project [duplicate]

Just installed Jenkins in Ubuntu 12.04 and I wanted to create a simple build that just clones a project and builds it.
It fails because it cannot tag. It cannot tag because it errors out saying "tell me who you are" apparently because I didn't set git settings UserName and UserEmail.
But, I should not need to set those, Jenkins is going to just clone the repository, why does it need the credentials if it's not going to push changes, why does it need to do a tag at all?
Full error log is:
Started by user anonymous
Checkout:workspace / /var/lib/jenkins/jobs/Foo.Bar.Baz/workspace - hudson.remoting.LocalChannel#38e609c9
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
Fetching upstream changes from git#mygithost.mydomain.local:foo-bar-baz/foo-bar-baz.git
Seen branch in repository origin/1.0
Seen branch in repository origin/1.5.4
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 479d37776b46283a946dd395c1ea78f18c0b97c7 (origin/1.0)
Checking out Revision 479d37776b46283a946dd395c1ea78f18c0b97c7 (origin/1.0)
FATAL: Could not apply tag jenkins-Foo.Bar.Baz-2
hudson.plugins.git.GitException: Could not apply tag jenkins-Foo.Bar.Baz-2
at hudson.plugins.git.GitAPI.tag(GitAPI.java:737)
at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1320)
at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1268)
at hudson.FilePath.act(FilePath.java:758)
at hudson.FilePath.act(FilePath.java:740)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1268)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:565)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:453)
at hudson.model.Run.run(Run.java:1376)
at hudson.matrix.MatrixBuild.run(MatrixBuild.java:220)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:175)
at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66)
Caused by: hudson.plugins.git.GitException: Command "git tag -a -f -m Jenkins Build #2 jenkins-Foo.Bar.Baz-2" returned status code 128:
stdout:
stderr:
*** Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident <jenkins#somehostname.(none)> not allowed
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:786)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:748)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:758)
at hudson.plugins.git.GitAPI.tag(GitAPI.java:735)
... 13 more
The idea of tagging when pulling/cloning a repo is common to most Build Scheduler out there:
Hudson-Jenkins, but also CruiseControl (The build label determined by the labelincrementer), or RTC Jazz Build Engine (where they are called "snapshots").
The idea is to set a persistent record of the input to a build.
That way, the code you are pulling, even if it wasn't tagged, is tagged automatically for you by the build scheduler, in order to be able to get back to that specific build later.
If that policy (always tagging before a build) is set, then Jenkins will need to know who you are in order to make a git tag (it is a git object with an author attached to it: user.name and user.email).
However, as mentioned in " Why hudson/jenkins tries to make commit? ":
Checks "Skip internal tag" config under "Advanced..." in section "Source code management".
That should avoid that extra tagging step you appear to not need.
As for how to set user.email and user.name,
In jenkins, go to "Manage Jenkins" > "Configure System"
and scroll down to "Git plugin" and there you will find
enter your email and name, you're good to go.
I used the solution above by iecanfly . Using my git user name and password didnt work , I
entered
username : jenkins
email : jenkins#localhost
That fixed the issue.
You can also SSH into Jenkins and navigate over to the workspace directory, and then you can just run the git config user.name and user.email commands normally.
If you are running Jenkins in a Docker container, you'd need to exec into the container docker exec -it <CONTAINER_ID> sh then run the suggested git commands with your email and name.