7

I am completely new to Jenkins (and Stackoverflow) and I am setting up a simple Jenkins job to poll a git repository.

1) I created a git repositoy on my local machine. 2) I created a Jenkins Freestyle job and on the configure screen entered the following parameters:

Repository URL: media@127.0.0.1:/home/media/git_repo_remote Credentials: none

The following error appears under the "Repository URL" text field:

Failed to connect to repository : Command "git ls-remote -h media@127.0.0.1:/home/media/git_repo_remote HEAD" returned status code 128:
stdout: 
stderr: Host key verification failed. 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

I then changed the repository URL to "https:///127.0.0.1/home/media/git_repo_remote" and receive the following in the log:

Started by an SCM change
Building in workspace /var/lib/jenkins/workspace/First Job
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https:///127.0.0.1/home/media/git_repo_remote # timeout=10
Fetching upstream changes from https:///127.0.0.1/home/media/git_repo_remote
 > git --version # timeout=10
 > git fetch --tags --progress https:///127.0.0.1/home/media/git_repo_remote +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
 > git rev-parse origin/master^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE

Any help would be greatly appreciated.

Thanks

TheShwiftmeister
  • 71
  • 1
  • 1
  • 2
  • 1
    Your ssh key verification failed. Make sure you have valid privileges to the key. – danglingpointer Jun 14 '17 at 20:53
  • possible duplicate of https://stackoverflow.com/questions/22031862/while-building-a-git-project-from-jenkins-it-shows-an-error-like-couldnt-find-a/68049453#68049453 – Atul KS Sep 22 '22 at 00:20

3 Answers3

6

Please check your branch where repositories hosted either main or Master

if repositories hosted in main , then Branches to build to */main if repositories hosted in master,then Branches to build to */master

4

So I have 3 suggestions:

  1. Regarding "https:///127.0.0.1/home/media/git_repo_remote" as git remote url - are you sure you have http server configured properly? Did you try opening this address in any browser on jenkins machine (or agent on which jenkins is executing its jobs) ?

  2. Reegarding "media@127.0.0.1:/home/media/git_repo_remote" as git remote - as @LethalProgramme mentioned the problem is that host verification key for localhost on jenkins machine (agent) is incorrect. So in some moment of time SSH host verification key for your jenkins machine has changed. What you can do is to ssh to that machine and execute: ssh-keygen -R 127.0.0.1 or ssh-keygen -R localhost as the same user as jenkins. See this question and it's answers for more details.

  3. I believe the easiest solution would be to use git local protocol intead of ssh or https. So set up you remote url to: /home/media/git_repo_remote or file:///home/media/git_repo_remote

running.t
  • 5,329
  • 3
  • 32
  • 50
4

Please check if the repo is using main or master and accordingly change the same in you jenkins JOB configuration

Source code Management > Branches to Build - > /*main or /*master ( As per your REPO on gitlab or github or any other scm platform )

enter image description here

Karan
  • 443
  • 5
  • 14