Gerrit Prolog Rules: Getting started - prolog

I would like to alter the commit rules for gerrit but somehow I am seemingly unable to follow the steps described in the cookbook (for example here:
http://saros-build.imp.fu-berlin.de/gerrit/Documentation/prolog-cookbook.html#_the_rules_pl_file )
On my local gerrit system I simply created an empty project
ssh user#localhost -p 29418 gerrit create-project --empty-commit --name demo-project
Next I cloned the new project
git clone ssh://user#localhost:29418/demo-project
Then according to the description I tried
/demo-projectmaster% git fetch origin refs/meta/config:config
which resulted in
fatal: Couldn't find remote ref refs/meta/config
Could you tell me what I am doing wrong? Feels like something very basic...
Thanks,
JS

it was due to missing access criteria.
I had to (in gerrit) grant the user explicit Read/Submit rights on refs/meta/config despite the user being in the administrator group.
Jörg

Related

Jenkins git authentication failed with correct credentials on Windows

I'm currently using Jenkins on Windows 10, and using git as version control system.
Although I provided correct repository URL and credential, I cannot use jenkins with error below.
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git#URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Credential and URL doesn't seems wrong, since this build success previously with same credential. The only change after successful build was one line in build script.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
After I success with this script, git setting keeps failed. Is there any problem with that line? And how can I fix it?
EDIT
Problem solved! For anyone who has same problem, it was problem with the system user! Since ssh key stores in each user space, jenkins cannot detect where the ssh key located. Therefore, go to 'service' in windows, and change user of jenkins service to the user who has correct ssh key. It solved my problem!
Seems there is some problem in Jenkins.
It cannot locate OpenSSH folder in System32, and so that I cannot get log with it.
That would explain why the main Jenkins controller (aka "master" in old terminology) cannot contact the Git repository (assuming an SSH URL here, with technical remote user account "git")
Try and remove that git configuration to see if the error persists: Git should fall back to its own ssh.exe, packaged with Git For Windows.
As noted by the OP, this only works if said Jenkins is run as a user account, not as the system account.
Only then will it be able to access the %USERPROFILE%\.ssh folder.

When I try to push my app to Heroku I get this response:

When I try to push my app to Heroku I get this response:
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.
You should:
Install heroku CLI plugin
Sign in using command heroku login
Add heroku as remote repository (gheroku git:remote -a YOUR_PROJECT_NAME)
Than you can push
You can find instructions here https://devcenter.heroku.com/articles/git
The issue was caused due to your project name used by another developer on heroku remote server. However, you need to change your project name and use the new name to create empty git repository on heroku server by following the command below before you push your project.
For instance, assumed you have changed your project name and is called foodproject-v2-app-launch
Note that your project name must not more than 30 characters on heroku server and must not be capitalize including special symbol except - and numbers.
Now, go to your terminal and 'cd in' to your project directory then run the below code.
Code 1: $ git init
Code 2: $ git add .
Code 3: $ git commit -m "Your Initial or Second commit"
Code 4: $ heroku create
Code 5: $ touch Procfile
Now open your Procfile with editor and add the following code and save it.
Code: web: node app.js
Code 6: $ git push heroku master
or
Code 6.1: $ git push heroku main
That should solve the issue mentioned above. Or refer to this article to read more https://devcenter.heroku.com/articles/git

GitHub - Using multiple deploy keys on a single server

Background
I have a system where when I push changes to my Repository, A web hook sends a request to my site which runs a bash script to pull the changes and copy any updated files.
I added a second repository with its own deploy key but after doing so i was getting a permission denied error when trying to pull changes.
Question
Is there a way to use 2 deploy key's on the same server?
Environment Details
Site uses Laravel 5.6, Symfony used to run shell script
Git 1.7
Go Daddy web hosting (Basic Linux one)
Notes
Script just runs git pull command
Error given is " Permission denied (publickey) "
SHH is used as a deploy key so only read access, there is one other project also using a deploy key on the same server
Thank you in advance for you help! Any other suggestions are welcome!
Edit #1
Edited post to reflect true problem as it was different to what I though (Feel free to revert if this is bad practice), please see answer below for details and solution
What i though was an issue with authentication what actually an issue with the git service not knowing which ssh key to use as i had multiple on the server.
The solution was to use a config file in the .ssh folder and assign alias to specify which ssh key to use for git operations in separate repositories.
Solution is here: Gist with solution
This gist explains the general idea, it suggests using sub-domains however a comment further down uses alias which seems neater.
I have now resolved the issue and the system is working fine with a read-only, passphrase-less deploy key.
This can be done by customizing the GIT_SSH_COMMAND. As ssh .config only gets the host, you have to create aliases to handle different paths. Alternatively, as the git CLI sends the path of the repo to the GIT_SSH_COMMAND, you can intercept the request in a custom script, added in between git and ssh.
You can create a solution where you extract the path and add in the related identity file, if available on the server.
One approach to do this can be found here.
Usage:
cp deploy_key_file ~/.ssh/git-keys/github-practice
GIT_SSH_COMMAND=custom_keys_git_ssh git clone git#github.com:github/practice.git

How can I solve "We were unable to install a project on your server" in forge laravel?

If I install repository in forge, there exist error like this :
Cloning into 'testshop.co.id'...
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The full error like this :
How can I solve this error?
Double-check your actual ssh URL and see if:
GitLab recognizes you (display a "Welcome" message)
ssh -T git#your.gitlab.server
GitLab has you listed as the owner or member of the project you want to access (for that, you need to go to the GitLab web pages interface)
Are you sure that your repository link is correct? The error is that it cannot find your repository.
It should be something along the lines of UserName/ProjectName .
To ensure what it is go to whatever source control that you use and look in the URL so for my github project:
https://github.com/KyleWardle/RomanNumerals
The link you would put in forge would be
KyleWardle/RomanNumerals
My Forge:

Unable to clone git repository from siteground

I'm trying to set up MS WebMatrix to use a Git repository from my siteground hosting account. I created the repository using their cpanel plugin and it tells me that I can clone it using this command
git clone ssh://username#sm3.siteground.biz:18765/home/username/public_html/
I replaced username of course and I created an rsa key using ssh-keygen. In the Webmatrix GUI it just opens a window saying "Clone is in progress" but it doesn't to anything.
And when I run that command in PowerShell, this is the output:
Cloning into 'public_html'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Any help is highly appreciated!
EDIT:
I haven't used github before but I'm pretty sure I'm not connecting to it. The repository is on siteground's server I think. Anyway, I couldn't figure it out in PowerShell so now I'm using putty to load the appropriate key and connect using an external git tool (source tree) that doesn't use the same ssh client as PowerShell. That is the solution that's working for me now.
I'll leave this question open as maybe someone comes around and can help with how to set this up using PowerShell.
The missing piece to the Siteground guide is:
Create a blank file in ~/.ssh/ or C:\Users\username\.ssh on your computer. It does not matter what you name it. I named it siteground_dsa. You could also name it id_dsa_siteground.
Copy the private ssh key that you get from siteground.com and paste the whole of it in the this newly created file.
Open Git Bash locally on your computer and run the following command
$ eval ssh-agent -s
Then run the following. Remember to use the filename that you gave it.
$ ssh-add ~/.ssh/siteground_dsa
Now you need to enter the passphrase for the ssh key. You will have defined it when creating the ssh key.
Now you should be logged in and you can run git clone the directory of your wish.
git clone ssh://username#ams14.siteground.eu:18765/home/username/public_html/
To permanently add the SSH key extend ~/.ssh/config with the following and updating server_name and username.
Host server_name
User username
Port 18765
IdentityFile ~/.ssh/siteground_dsa
keep in mind that for Windows operators, you should write eval $(ssh-agent)
eval $(ssh-agent)
chmod 600 file_name
ssh-add C:\Users\username\.ssh\siteground
Then you can easily clone your file into your local server following inserting your passphrase of the SSH key.
GitHub isn't able to authenticate you. Probably your key isn't associated with your GitHub account.
Take a look to GitHub's recommended method

Resources