I am trying to pull the code form GIT using GIT Plugin Jenkins and the job is running on a slave machine.
MASTER
system has http_proxy=mycom.domain.com:80
and in SLAVE
system there is no http_proxy
defined.
Whenever I am doing git clone locally in the SLAVE
machine it works perfectly, however from Jenkins I haven't been successful.
It is throwing the following error:
Building remotely on SLAVE in workspace /data/test
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://github.domain.com/Project-Digital/Project-eCommerce.git # timeout=10
Fetching upstream changes from https://github.domain.com/Project-Digital/Project-eCommerce.git
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
Setting http proxy: mycom.domain.com:80
> /usr/bin/git fetch --tags --progress https://github.domain.com/Project-Digital/Project-eCommerce.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.domain.com/Project-Digital/Project-eCommerce.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress https://github.domain.com/Project-Digital/Project-eCommerce.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: Failed connect to github.build.ge.com:80; Operation now in progress while accessing https://github.domain.com/Project-Digital/Project-eCommerce.git/info/refs
Is it because the MASTER
system trying to set http proxy which is not present in the SLAVE
system?
If yes, how to prevent it?
Or, is there something else I am missing?
Turned out it was a proxy issue.
While pulling the code from GIT using Jenkins it was setting the
http_proxy
tomycom.domain.com:80
(MASTER
machine proxy) and this proxy was not required in theSLAVE
machine.So, I just added the GIT URL to No Proxy Host section
(Manage Jenkins -> Manage Plugins -> Advanced -> HTTP Proxy Configuration -> Added GIT URL in No Proxy Host field)
in Jenkins and now it is working fine.Today i also set up the jenkins with git repository, worked for me, hope this helps,
To connect git with jenkins do following steps :
STEP 1. After successfull installation of plugins create a new job like this:
1.create a Job name
2.checked the radio button of Build a maven software project
3.click OK
STEP 2. Now checked the radio button for Git enter the uri of your git repository.
STEP 3. If you will see the error like
Failed to connect to repository : Command "git ls-remote -h git@example.git HEAD" returned status code 128: stdout: stderr: fatal: 'git@example.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly
You have to do some more configuration:
1.Go to to the terminal
2.Run this command : sudo visudo
3.Add %jenkins ALL=NOPASSWD: ALL in this file where sudo previlage is defined.and close the file.
4.login as jenkins user via command : sudo su jenkins
5.Create a .ssh directory in the jenkins home directory.
6.create the public private key pair like this.
Generating SSH Keys:
1: Check for SSH keys
First, we need to check for existing ssh keys on your computer. Open up Terminal and run:
cd ~/.ssh Checks to see if there is a directory named ".ssh" in your user directory
If it says "No such file or directory" go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.
2: Generate a new SSH key
To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.
ssh-keygen -t rsa -C "your_email@example.com"
Creates a new ssh key, using the provided email as a label Generating public/private rsa key pair. Enter file in which to save the key (/home/you/.ssh/id_rsa): Now you need to enter a passphrase or file.press enter without to write any thing.
Which should give you something like this:
Your identification has been saved in /home/you/.ssh/id_rsa.
Your public key has been saved in /home/you/.ssh/id_rsa.pub. The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
3: Add your SSH key to GitHub
Go to your Account Settings
4 : Under Source Management tag,
Under Execute Shell tag you can put your scripts to execute.
Finally Click on Build Now to create the build, Open console to check the status.
Before pulling the project, try to set the HTTP proxy in global configuration:
$> git config --global http.proxy http://mycom.example.com:80
If you need to provide a username and a password for your proxy, you can use:
$> git config --global http.proxy http://example.com\\<yourUsername>:<yourPassword>@<yourProxyServer>:80