简体   繁体   中英

Git push from TeamCity 9.0.3 build

I'm trying to make a TeamCity build configuration that checks out a git repo, makes a small change to a text file in the repo, then pushes the change back to the repo. I am having a hell of a time getting the git push command to work from the Ubuntu build agent.

I have tried both ssh authentication and https authentication:

With HTTPS I get this error:

could not read Username for 'https://github.com': No such device or address

So I tried:

git config user.name "<my username>"
git config user.email "<my email>"

Same error.

With SSH I get this error:

ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.

I tried writing my key in the working directory and getting git to use it like this:

cat << EOF > github.key
%secure:teamcity.password.chambm ssh key%
EOF
chmod 600 github.key

GIT_SSH_COMMAND='ssh -i github.key' git push origin master
shred github.key

Same error.

As far as I can tell, there are no unusual settings in /etc/ssh_config or /etc/gitconfig , and ~/.ssh/config does not exist. Why is this so hard? Why does git call ssh_askpass even though I'm giving it a private key to use?

git --version is 2.7.4

Environment variables:

export BUILD_NUMBER='44'
export BUILD_VCS_NUMBER='50e0d54d7045fcf0bd6949a06d82ac2f118bc5d9'
export BUILD_VCS_NUMBER_ProteoWizard_HttpsGithubComBiocondaBiocondaRecipes='50e0d54d7045fcf0bd6949a06d82ac2f118bc5d9'
export DISPLAY=':3'
export FIREFOX38='/tcuser/apps/firefox38/firefox'
export FIREFOX45='/tcuser/apps/firefox45/firefox'
export FIREFOX52='/tcuser/apps/firefox52/firefox'
export FIREFOX_HOME='/usr/bin/firefox'
export HOME='/home/tcuser'
export JAVA_HOME='/usr/lib/jvm/default-java'
export JDK_17='/usr/lib/jvm/java-7-sun'
export JDK_18='/usr/lib/jvm/java-8-sun'
export JRE_HOME='/usr/lib/jvm/default-java'
export LANG='en_US.UTF-8'
export LOGNAME='tcuser'
export MAIL='/var/mail/tcuser'
export NUMBER_OF_CORES='4'
export OLDPWD='/tcuser/apps/teamcity/agent/bin'
export PATH='/home/tcuser/bin:/home/tcuser/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin'
export PERL_HOME='/usr/bin'
export PWD='/mnt/teamcity/agent/work/2cc04074d294b6fa'
export PYTHON2='/usr/bin/python'
export PYTHON3='/usr/bin/python3'
export R_HOME='/tcuser/apps/R/default'
export SHELL='/bin/bash'
export SHLVL='1'
export TEAMCITY_AGENT_OPTS='-Duser.timezone=America/Los_Angeles'
export TEAMCITY_BUILDCONF_NAME='Bumbershoot update bioconda'
export TEAMCITY_BUILD_PROPERTIES_FILE='/mnt/teamcity/agent/temp/buildTmp/teamcity.build7482307983791518712.properties'
export TEAMCITY_CAPTURE_ENV='"/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" -jar "/tcuser/apps/teamcity/agent/plugins/environment-fetcher/bin/env-fetcher.jar"'
export TEAMCITY_GIT_PATH='/usr/bin/git'
export TEAMCITY_PROCESS_FLOW_ID='1039593210152446'
export TEAMCITY_PROCESS_PARENT_FLOW_ID=''
export TEAMCITY_PROJECT_NAME='Bioconda'
export TEAMCITY_VERSION='9.0.3 (build 32334)'
export TEMP='/mnt/teamcity/agent/temp/buildTmp'
export TMP='/mnt/teamcity/agent/temp/buildTmp'
export TMPDIR='/mnt/teamcity/agent/temp/buildTmp'
export TZ='PST8PDT'
export USER='tcuser'
export XDG_RUNTIME_DIR='/run/user/1002'
export XDG_SESSION_ID='c8'

Regarding https, you need:

  • to make sure the URL is

     https://<username>@github.com/<username>/arepo 
  • there is a credential manager to cache the password

     git config -l credential.helper 

See " Git Tools - Credential Storage " and this setting .

Then try manually a git ls-remote https://... in order to trigger a prompt asking for your password, which will be cached.
Then TeamCity will be able to reuse those cached credentials.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM