Skip to content

Commit

Permalink
Perform docker login
Browse files Browse the repository at this point in the history
  • Loading branch information
bdpiprava committed Aug 30, 2018
1 parent ed698e6 commit b77b67f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ def get_var(name)
value
end

class Docker
def self.login
token = ENV["TOKEN"]
raise "Environment variable TOKEN is not specified." unless token
FileUtils.mkdir_p "#{Dir.home}/.docker"
File.open("#{Dir.home}/.docker/config.json", "w") do |f|
f.write({:auths => {"https://index.docker.io/v1/" => {:auth => token}}}.to_json)
end
end
end

gocd_full_version = versionFile('go_full_version') || get_var('GOCD_FULL_VERSION')
gocd_version = versionFile('go_version') || get_var('GOCD_VERSION')
gocd_git_sha = versionFile('git_sha') || get_var('GOCD_GIT_SHA')
Expand All @@ -20,6 +31,9 @@ download_url = ENV['GOCD_SERVER_DOWNLOAD_URL'] || "https://download.gocd.org/exp

tag = ENV['TAG']

# Perform docker login if token is specified or error out
Docker.login

task :create_dockerfile do
template = File.read('Dockerfile.erb')
renderer = ERB.new(template, nil, '-')
Expand Down

0 comments on commit b77b67f

Please sign in to comment.