module Jets::Git class Codebuild def params params = { git_system: 'codebuild', git_branch: git_branch, git_sha: git_sha, git_dirty: false, # git_message: nil, # git_version: nil, } params[:git_url] = git_url if git_url params end def git_branch ENV['CODEBUILD_SOURCE_VERSION'] end def git_sha ENV['CODEBUILD_RESOLVED_SOURCE_VERSION'] end def git_url "#{host}/#{full_repo}" end def host uri = URI(ENV['CODEBUILD_SOURCE_REPO_URL']) # https://github.com/ORG/REPO "#{uri.scheme}://#{uri.host}" end # ORG/REPO def full_repo uri = URI(repo_url) uri.path.sub(/^\//,'') end # https://github.com/ORG/REPO def repo_url # https://github.com/ORG/REPO.git ENV['CODEBUILD_SOURCE_REPO_URL'].sub('.git','') end end end