class Capistrano::Jenkins

Jenkins as SCM for Capistrano

@author Jeff Byrnes <jeff@evertrue.com>

Public Instance Methods

allowed_statuses() click to toggle source
# File lib/capistrano/jenkins.rb, line 24
def allowed_statuses
  statuses = %w(success)

  @allowed_statuses ||= begin
    statuses << 'unstable' if fetch(:jenkins_use_unstable)

    statuses
  end
end
artifact_build_number() click to toggle source
# File lib/capistrano/jenkins.rb, line 78
def artifact_build_number
  @artifact_build_number ||= jenkins_api_res['number']
end
artifact_build_number_opt() click to toggle source
# File lib/capistrano/jenkins.rb, line 74
def artifact_build_number_opt
  fetch(:jenkins_build_number, 'lastBuild')
end
artifact_ext() click to toggle source
# File lib/capistrano/jenkins.rb, line 70
def artifact_ext
  @artifact_ext = File.extname(artifact_filename)
end
artifact_file_opt() click to toggle source
# File lib/capistrano/jenkins.rb, line 62
def artifact_file_opt
  fetch(:jenkins_artifact_file, '*zip*/archive.zip')
end
artifact_filename() click to toggle source
# File lib/capistrano/jenkins.rb, line 66
def artifact_filename
  @artifact_filename = File.basename(artifact_file_opt)
end
artifact_is_zip?() click to toggle source
# File lib/capistrano/jenkins.rb, line 58
def artifact_is_zip?
  artifact_ext == '.zip'
end
artifact_url() click to toggle source
# File lib/capistrano/jenkins.rb, line 82
def artifact_url
  "#{repo_url}/#{artifact_build_number_opt}/artifact/#{artifact_file_opt}"
end
auth_opts() click to toggle source
# File lib/capistrano/jenkins.rb, line 42
def auth_opts
  if jenkins_user && jenkins_pass
    { http_basic_authentication: [jenkins_user, jenkins_pass] }
  else
    {}
  end
end
curl_auth() click to toggle source
# File lib/capistrano/jenkins.rb, line 50
def curl_auth
  if jenkins_user && jenkins_pass
    "--user '#{jenkins_user}:#{jenkins_pass}'"
  else
    ''
  end
end
jenkins_api_res() click to toggle source
# File lib/capistrano/jenkins.rb, line 86
def jenkins_api_res
  jenkins_job_api_url = "#{repo_url}/#{artifact_build_number_opt}/api/json"

  res ||= open(jenkins_job_api_url, auth_opts.merge(ssl_opts)).read

  @jenkins_api_res = JSON.parse(res)
rescue => e
  abort "Request to '#{jenkins_job_api_url}'} failed: #{e}"
end
jenkins_pass() click to toggle source
# File lib/capistrano/jenkins.rb, line 18
def jenkins_pass
  @jenkins_pass ||= begin
    fetch(:jenkins_pass) if fetch(:jenkins_pass)
  end
end
jenkins_user() click to toggle source
# File lib/capistrano/jenkins.rb, line 12
def jenkins_user
  @jenkins_user ||= begin
    fetch(:jenkins_user) if fetch(:jenkins_user)
  end
end
ssl_opts() click to toggle source
# File lib/capistrano/jenkins.rb, line 34
def ssl_opts
  if fetch(:jenkins_insecure)
    { ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
  else
    { ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER }
  end
end