summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Lapierre <mlapierre@gitlab.com>2018-09-15 07:47:09 -0400
committerMark Lapierre <mlapierre@gitlab.com>2018-09-15 07:47:09 -0400
commit53af9d189e5087b526683777d59786277e2528e7 (patch)
treef9ad497e3f05cf2dedbf27d3f38b1464d38ace3d
parent01c4d9020036cb02b2f9cd2864337b8c05286e55 (diff)
downloadgitlab-ce-ml-qa-ssh-spec-only.tar.gz
Skip port on keyscan if there is noneml-qa-ssh-spec-only
-rw-r--r--qa/qa/git/repository.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
index d4c7dc13553..79c87b1d661 100644
--- a/qa/qa/git/repository.rb
+++ b/qa/qa/git/repository.rb
@@ -97,7 +97,10 @@ module QA
File.chmod(0700, @private_key_file)
@known_hosts_file = Tempfile.new("known_hosts_#{SecureRandom.hex(8)}")
- run_and_redact_credentials("ssh-keyscan -p #{@uri.port} #{@uri.host} >> #{@known_hosts_file.path}")
+ keyscan_params = ['-H']
+ keyscan_params << "-p #{@uri.port}" if @uri.port
+ keyscan_params << @uri.host
+ run_and_redact_credentials("ssh-keyscan #{keyscan_params.join(' ')} >> #{@known_hosts_file.path}")
configure_ssh_command("ssh -i #{@private_key_file.path} -o UserKnownHostsFile=#{@known_hosts_file.path}")
end
@@ -118,6 +121,7 @@ module QA
# Since the remote URL contains the credentials, and git occasionally
# outputs the URL. Note that stderr is redirected to stdout.
def run_and_redact_credentials(command)
+ puts command
Open3.capture2("#{command} 2>&1 | sed -E 's#://[^@]+@#://****@#g'")
end
end