Git clone problem
Hello,
Some input for the problem:
- TeamCity Professional 2017.2 build 50574 (Windows 2012 R2 6.3.9600)
- Repository it hosted by https://bitbucket.org
- Between the server and BitBucket there is a proxy (without auth).
- HTTPS is used to fetch Git repo (SSH port is closed by corporate firewall) with password-base auth.
When I configured VCS root and proxy in internal settings, "Test connection" button works well. Git is installed, proxy configured and clone from command-line is also ok. But when build is fetching project from this repo, I got:
[2017-12-19 14:44:14,898] INFO [ical executor 4] - jetbrains.buildServer.VCS - Collecting changes for VCS root "ACME BitBucket" {instance id=4, parent internal id=1, parent id=acme_bitbucket, description: "https://AcmeUser@bitbucket.org/acme/acme.git#refs/heads/master"} from state RepositoryState{defaultBranch='refs/heads/master', revisions={refs/heads/master: 3c5ac706247344ef4f4e33362c59c8dda82c79ee}} to state RepositoryState{defaultBranch='refs/heads/master', revisions={refs/heads/master: 3c5ac706247344ef4f4e33362c59c8dda82c79ee}}
[2017-12-19 14:46:24,068] WARN [ical executor 4] - cs.ConnectionStateReporterImpl - Unable to collect changes for [ACME :: ACME Build {id=acme_build, internal id=bt1}]: jetbrains.buildServer.vcs.VcsRootVcsException: Error collecting changes for VCS repository '"ACME BitBucket" {instance id=4, parent internal id=1, parent id=acme_bitbucket, description: "https://Yarmonov@bitbucket.org/acme/acme.git#refs/heads/master"}'
'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-76EAA288.git).
stderr: https://bitbucket.org/acme/acme.git: cannot open git-upload-pack
stdout: [2017-12-19 14:45:21,026] INFO - Triggers.vcs.git.GitServerUtil - Failed to list remote refs, continue without pruning removed refs
org.eclipse.jgit.errors.TransportException: https://bitbucket.org/acme/acme.git: cannot open git-upload-pack
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:530)
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:315)
at jetbrains.buildServer.buildTriggers.vcs.git.GitServerUtil.pruneRemovedBranches(GitServerUtil.java:351)
at jetbrains.buildServer.buildTriggers.vcs.git.GitServerUtil.pruneRemovedBranches(GitServerUtil.java:335)
at jetbrains.buildServer.buildTriggers.vcs.git.Fetcher.pruneRemovedBranches(Fetcher.java:128)
at jetbrains.buildServer.buildTriggers.vcs.git.Fetcher.fetch(Fetcher.java:107)
at jetbrains.buildServer.buildTriggers.vcs.git.Fetcher.main(Fetcher.java:64)
Caused by: java.net.ConnectException: Connection time out: bitbucket.org
at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:174)
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:481)
... 6 more
exit code: 1
I've also tried to use run both TeamCity server and TeamCity Agent service using account that definitely has git configured and can clone successfully from the command line.
Please sign in to leave a comment.
Hi Stanislav,
please, check our docs on setting up teamcity to use a proxy for outgoing connections here: https://confluence.jetbrains.com/pages/viewpage.action?pageId=74845225#HowTo...-ConfigureTeamCitytoUseProxyServerforOutgoingConnections
This is for the server, the piece right below it is for the agents. The server will need it for checking the repos, the agents for checking out the data.
I have exactly the same problem (okay, not bitbucket, but our own git repository)
Proxy in TeamCity Server is configured. Git global is configured with a proxy too. http_proxy/https_proxy at linux level is set.
But the agent will not connect to the repository via proxy.
When I configure the proxy stuff in teamcity agent properties, the agent is not able to connect to the teamcity server. Thats because the proxy is for teamcity server connection, and not (only?) for git.
Why is there no "nonProxyHosts" property for the agent settings?
Hi Steffen,
TeamCity uses the git executable on the agent, so connecting to the repository should be done via proxy as long as git is configured to do so, even if the agent itself isn't. Can you login into the agent with the same user that runs the build agent's process and check that it works for it from a command line?
Hi Denis,
Agent is running as root (yeah not fine) at the same server as teamcity
[root@teamcity2018 bin]# ps -ef |grep agent
root 8967 1 0 Apr02 ? 00:07:55 /usr/lib/jvm/jre/bin/java -ea -Xms16m -Xmx64m -cp ../launcher/lib/launcher.jar jetbrains.buildServer.agent.Launcher -ea -Xmx384m -Dteamcity_logs=../logs/ -Dlog4j.configuration=file:../conf/teamcity-agent-log4j.xml jetbrains.buildServer.agent.AgentMain -file ../conf/buildAgent.properties
Git is configured globally with proxy as root:
[root@teamcity2018 bin]# git config --list
http.proxy=192.168.XX.XX:8080
https.proxy=192.168.XX.XX:8080
https.proxy=192.168.XX.XX:8080
http.proxy=192.168.XX.XX:8080
git clone on command line is working fine:
[root@teamcity2018 temp]# git clone https://XXX@XXX.com/git/r/XXX/XX-XXX.git
Cloning into 'XX-XXXX'...
Password for 'https://XXX@XXX.com':
remote: Counting objects: 1858, done
remote: Finding sources: 100% (1858/1858)
remote: Getting sizes: 100% (1237/1237)
remote: Total 1858 (delta 590), reused 1858 (delta 590)
Receiving objects: 100% (1858/1858), 126.62 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (590/590), done.
[root@teamcity2018 XX-XXX]# git pull
Already up-to-date.
[root@teamcity2018 XX-XXX]# git fetch
[root@teamcity2018 XX-XXX]#
But at the TeamCity run configuration:
at jetbrains.buildServer.buildTriggers.vcs.git.Fetcher.main(Fetcher.java:64)
Caused by: java.net.UnknownHostException: XXX.com: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
Ahh wait ipv6? Let me check this...
Hmm no. no luck, even with disabled v6:
at jetbrains.buildServer.buildTriggers.vcs.git.Fetcher.main(Fetcher.java:64)
Caused by: java.net.UnknownHostException: XXX.com: Name or service not known
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
Okay i found a solution:
Added this to the agent.sh script:
TEAMCITY_AGENT_OPTS="-Dhttps.proxyHost=192.168.XX.XX -Dhttps.proxyPort=8080 -Dhttps.nonProxyHosts=localhost|192.168.XX.* -Dhttp.proxyHost=192.168.XX.XX -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=localhost|192.168.XX.*"