Can't get information from git server using spring cloud config - linux

I have a Spring Cloud Config project where I connect to my github account, my project works fine but here in my job my boss want to make a git server and use that instead of the github account, so after install git on my server (linux, I created a repository like this:
git init configuracionCarnet
cd configuracionCarnet
git pull <url from github>
git remote add origin user#ip:/home/desarrollo/configuracionCarnetDesarrollo.git
On my Spring cloud config project I change my application.yml like this:
spring:
cloud:
config:
server:
git:
uri: user#ip:/home/desarrollo/configuracionCarnet.git
username: user
password: password
server:
port: 8001
I run the project and starts ok but when I execute the http://localhost:8001/health it throws that the project is down so I can't connect to the git server, what am I doing wrong?,
Thanks in advance

You do not create a server with …remote add….
You also do not create a server with your Spring config by putting a non-existent URL into your config.
Possibilities:
Hide GitHub with Spring by putting your GitHub URL in your Spring config, as you did before.
Hide GitHub with a Gitblit mirror (you have to install Gitblit and google a bit)
Use Gitblit as a substitute for GitHub.

Related

create(clone) the same app for development in heroku

I am having the app http://example.com in heroku. So I need to create(clone) the same app for my development in subfolder http://example.com/subfolder. How to do this. Any help will be much appreciated.
Note:
I am having only heroku access, no domain login available with me.
Heroku nodejs application.
I am new to Heroku. I have clonned the same app in my localhost:5000. But needed online development environment.
Finally I created the staging environment. My development environment is in local.
Once I clone my production app to my local, then I am creating the staging environment.
ref this link for downloading code from heroku. Ensure that you have downloaded the application slugs.
Once cloned into my local. I checked with localhost:5000. For this I have already installed node server and git in my windows 10.
heroku create --remote staging
after the above command, you will see the new staging environment(name will be auto generated) created in your Heroku login.
Click on that newly created app name in heroku login and then deploy tab, follow the procedure given in that. for which the link can be like this https://dashboard.heroku.com/apps/autogenerated-appname-12345/deploy/heroku-git
And in the final step git push heroku master I got the error
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Then I used git push staging master which is mentioned in this document.
Then I checked in the browser https://autogenerated-appname-12345.herokuapp.com/

Setting up SSH keys for github private repo access on Elastic Beanstalk

My Node.JS project contains references to private NPM repos hosted on github. This works fine locally, but I'm struggling to get this working on Elastic Beanstalk.
dependencies: {
...
"express": "^4.12.4",
"jsonwebtoken": "^5.0.5",
"my-private-module": "git#github.com:<my-user>/<my-repo>.git#<my-version>",
...
}
-
What I need is to be able to set up a working SSH configuration for git on my Elastic Beanstalk instances, without having to store secret keys etc in source control.
Obviously, the EB instances do not have the needed SSH keys to access my private github repos. If I use HTTPS style git URL's with username:password#github.com inlined, it works fine. It also works using the oauth token method offered by github (which is essentially a user:pass). But I do not want any credentials to be checked in to source control, so I'm trying to get cloning from github to work via SSH on my EB instances.
I've tried a million ways, including npm preinstall scripts according to this blog post, which used to work until npm2 where a change made preinstall to run after the tree is built, and the PR to fix that issue is still pending.
I've tried an .ebextensions commands configuration that tries to call git config to place an insteadof on git#github.com into a HTTPS URL with an OAUTH token coming from an environment variable (tricky in itself since env variables aren't set at this time in the startup cycle, and the lack of $HOME makes git config confused).
I've also tried various different ways using .ebextensions to setup SSH on my EB instances, including this solution from the comments on the mentioned blog post. This is basically where I'm stuck now.
I have successfully created a key pair, set it up on my github profile, and verified that the private key is usable from my local client to clone my repo
I have put my private key and a ssh config file on a private S3 bucket
I've created an .ebextensions files configuration which copies these two files from my S3 bucket into /tmp/.ssh/, according to this example
I've created a debug commands .ebextensions configuration which lists /tmp/.ssh and shows that the files were downloaded from S3 successfully:
/tmp/.ssh/config contains:
Host github.com
IdentityFile /tmp/.ssh/deploy_key
IdentitiesOnly yes
UserKnownHostsFile=/dev/null
StrictHostKeyChecking no
/tmp/.ssh/deploy_key contains my private key which is verified to work locally.
However, git still throws an error:
npm ERR! Command failed: git clone --template=/tmp/.npm/_git-remotes/_templates --mirror ssh://git#github.com/[.....]
npm ERR! Cloning into bare repository '/tmp/.npm/_git-remotes/git-ssh-git-github-com-[...]
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
I am now running out of ideas. My best guess would be that /tmp/.ssh is not the path where git goes to look for the ssh config file - it might have been when the linked solution was proposed but might have changed in later AMI:s etc. The environment used when EB is starting up seems to be a bit limited; commands are run as user nodejs but /tmp seems to be used as the home directory, even though $HOME is not set anywhere.
How can I get git to pick up my SSH config, and consequently use my SSH key? How can I find out where git looks for a SSH config file? Normally it's in ~/.ssh, but since $HOME is not set, well... This should be easy but is driving me nuts.
After a full day's struggle and finally stumbling over this answer to a very similar question I had previously missed, it turns out the correct place to put ssh keys in order to be picked up by git on EB is in /root/.ssh, not /tmp/.ssh, not /home/ec2-user/.ssh.
My final configuration (assuming there's a private SSH key located in a S3 bucket at <my-bucket>/github-eb-key, and the corresponding public key is registered with a github user having access to the repo(s)), using an AMI configured as 64bit Amazon Linux 2016.09 v3.3.0 running Node.js, and with the following in .ebextensions/01_ssh_setup.config:
Resources:
AWSEBAutoScalingGroup:
Metadata:
? "AWS::CloudFormation::Authentication"
:
S3Auth:
buckets:
- <my-bucket>
roleName:
? "Fn::GetOptionSetting"
:
DefaultValue: aws-elasticbeanstalk-ec2-role
Namespace: "aws:asg:launchconfiguration"
OptionName: IamInstanceProfile
type: s3
files:
/root/.ssh/github-eb-key:
authentication: S3Auth
mode: "000600"
owner: root
group: root
source: "https://s3-eu-west-1.amazonaws.com/<my-bucket>/github-eb-key"
/root/.ssh/config:
mode: "000600"
owner: root
group: root
content: |
Host github.com
IdentityFile /root/.ssh/github-eb-key
IdentitiesOnly yes
UserKnownHostsFile=/dev/null
StrictHostKeyChecking no

travis deployment Couldn't resolve host

I have setup travis-ci to deploy to azure website, travis use dpl for deployment,
but I get unable to resolve host:
fatal: unable to access 'https://username:!password#https://test-ci.azurewebsites.net/.scm.azurewebsites.net:443/https://test-ci.azurewebsites.net/.git/': Couldn't resolve host 'https'
but the actual git url at azure portal is:
https://username#test-ci.scm.azurewebsites.net:443/test-ci.git
As my test, we only need to provide the site name to the .travis.yml file. It is enough (do not use web app url or git url as the value of site). The following is my deploy part in .travis.yml.
deploy:
provider: azure_web_apps
username: "jambor1" # If AZURE_WA_USERNAME isn't set
password: "***" # If AZURE_WA_PASSWORD isn't set
site: "travistestja" # If AZURE_WA_SITE isn't set
verbose: true
Here is the result:
when you are creating deployment credentials don't use '#' character or other special characters which will break the git repository path created by azure local git deployment.
Follow article https://learn.microsoft.com/en-us/azure/app-service-web/scripts/app-service-powershell-deploy-local-git where you will see that git is using username and password both for connecting to git repository, so if there are some difference in actual repository path in azure portal and in travis ci that is not the actual problem.

Using gitlab behind router and portforwarding?

My current setup is that I have an Ubuntu VM with gitlab installed (gitlabVM). Gitlab is running on nginx over port 8888
My router is configured as the following:
External 4322 -> gitlabVM:22
External 8888 -> gitlabVM:8888
If I am at a remote location, how do I connect back to do a git clone?
Ive tried git+ssh://myuseringitlab#routerip:4322/root/repo.git but i get an error that there are no repositories.
the url in gitlab is git#localhost:root/repo.git.
Did you try this ?
git+ssh://git#routerip:4322/root/repo.git
You have to provide the git user. Your Gitlab user credentials are asked at the next step (if you don't use SSH auth).

How to upload a git repo to gerrit?

I installed the gerrit service on a ubuntu server,and my PC as client.
I created a git repo on my PC(with msysgit),and the question is :how can I upload the git repo to the Ubuntu server?Should I do some work on Ubuntu server first(i just installed gerrit and git service )?
First, you need to create the project on the Gerrit server using gerrit create-project.
Next, edit the project permissions if necessary to add the following for your user (Administrators group, probably):
Create reference
Forge committer identity
Forge author identity
This allows you to upload an existing history, perhaps committed by different people, bypassing the need to review every commit you select.
Finally, push your code:
git remote add gerrit gerritserver:project
git push gerrit master:refs/heads/master

Resources