1
votes

Everytime I try to build a Maven project hosted on a gitlab server with TeamCity, I get an error from the buildAgent. Both TeamCity and GitLab are on the same server.

It seems that the agent can't connect to gitlab but it does, because when I have to specify the pom.xml path in the build configuration section, I can navigate through the repository folders(http://prntscr.com/i8pyjf).

I have already tried different solutions:

  • I added both the root ssh and the ssh key of the ser that is running teamcity, both of them seem to work cause the test connection was succesful(http://prntscr.com/i8q0jf);
  • I added teamcity.git.use.native.ssh true in the buildAgent conf and the error log changed a little (the error is still the same but I get less lines)
  • I added teamcity.git.use.native.ssh true as a configuration parameter -> http://prntscr.com/i8pnqp (not sure if I did it right)
  • I tried adding the runAs plugin to force the user agent to use root

TeamCity version -> TeamCity Professional 2017.2.2 (build 50909)

Here's the error log:

[22:03:51] The build is removed from the queue to be prepared for the start
[22:03:51]  Collecting changes in 1 VCS root
[22:03:51]  [Collecting changes in 1 VCS root] VCS Root details
[22:03:51]  [VCS Root details] "[email protected]:Developer/BanlogBridge.git" {instance id=11, parent internal id=1, parent id=Ban_Git15180136106DeveloperBanlogBridgeGit, description: "[email protected]:Developer/BanlogBridge.git#master"}
[22:03:51]  [Collecting changes in 1 VCS root] Compute revision for '[email protected]:Developer/BanlogBridge.git'
[22:03:51]  [Compute revision for '[email protected]:Developer/BanlogBridge.git'] Upper limit revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51]  [Compute revision for '[email protected]:Developer/BanlogBridge.git'] Cannot find modification with revision 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51]  [Compute revision for '[email protected]:Developer/BanlogBridge.git'] No modification from VCS root is attached to build configuration, use upper limit revision
[22:03:51]  [Compute revision for '[email protected]:Developer/BanlogBridge.git'] Computed revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51]  Starting the build on the agent Default Agent
[22:03:52]  Clearing temporary directory: /usr/local/teamcity/buildAgent/temp/buildTmp
[22:03:52]  Publishing internal artifacts
[22:03:52]  [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[22:03:52]  [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[22:03:52]  Using vcs information from agent file: db80d9c7294729d5.xml
[22:03:52]  Checkout directory: /usr/local/teamcity/buildAgent/work/db80d9c7294729d5
[22:03:52]  Updating sources: auto checkout (on agent)
[22:03:52]  [Updating sources] Will use agent side checkout
[22:03:52]  [Updating sources] VCS Root: [email protected]:Developer/BanlogBridge.git
[22:03:52]  [VCS Root: [email protected]:Developer/BanlogBridge.git] revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:52]  [VCS Root: [email protected]:Developer/BanlogBridge.git] Git version: 2.7.4.0
[22:03:52]  [VCS Root: [email protected]:Developer/BanlogBridge.git] Will use native ssh (teamcity.git.use.native.ssh=true)
[22:03:52]  [VCS Root: [email protected]:Developer/BanlogBridge.git] Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)
[22:03:52]  [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git config core.sparseCheckout true
[22:03:52]  [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git show-ref
[22:03:52]  [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git show-ref refs/remotes/origin/master
[22:03:52]  [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] Commit '0d41a12c788798152c7da9327ef63b759f7d5b4c' is not found in local clone. Running 'git fetch'...
[22:03:52]  [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git fetch --progress origin +refs/heads/master:refs/remotes/origin/master
[22:03:52]  [Updating sources] Failed to perform checkout on agent: '/usr/bin/git fetch --progress origin +refs/heads/master:refs/remotes/origin/master' command failed.
exit code: 128
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.
[22:03:52]  Publishing internal artifacts
[22:03:52]  [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[22:03:52]  [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[22:03:52]  Build failed to start. Artifacts will not be published for this build
[22:03:52]  Build finished

Thank you for your help!

1

1 Answers

0
votes

It happens because known hosts database on the TeamCity agent machine doesn't contain the fingerprint of the Gitlab server. You can add it by running some command via ssh, e.g. git ls-remote <your repository url>, and agree to add the fingerprint if it's correct.

Actually TeamCity checks out code with known hosts database check disabled. Please check if you have anything related to Gitlab in the .ssh/config on the TeamCity agent machine.