Sha256: a41ccc91e82fc2903bf0081df93b7f7c1c69a8667b90049480da9e8410f7ca74

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module TerraspaceCiGitlab
  class Vars
    # Interface method. Hash of properties to be stored
    def data
      {
        build_system: "gitlab",   # required
        host: host,
        full_repo: full_repo,
        branch_name: branch_name,
        # urls
        pr_url: pr_url,
        build_url: ENV['CI_PIPELINE_URL'],
        # additional properties
        build_type: ENV['CI_PIPELINE_SOURCE'], # IE: merge_request_event
        pr_number: pr_number,  # set when build_type=pull_request
        sha: sha,
        # additional properties
        commit_message: ENV['CI_COMMIT_MESSAGE'],
        build_id: ENV['CI_PIPELINE_ID'],
        build_number: ENV['CI_PIPELINE_IID'],
      }
    end

    def host
      ENV['CI_SERVER_URL'] || 'https://gitlab.com'
    end

    def pr_url
      "#{host}/#{full_repo}/-/merge_requests/#{pr_number}" if pr_number
    end

    def pr_number
      ENV['CI_MERGE_REQUEST_IID']
    end

    def branch_name
      ENV['CI_COMMIT_REF_NAME']
    end

    def sha
      ENV['CI_COMMIT_SHA']
    end

    def full_repo
      ENV['CI_PROJECT_PATH']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
terraspace_ci_gitlab-0.2.0 lib/terraspace_ci_gitlab/vars.rb
terraspace_ci_gitlab-0.1.1 lib/terraspace_ci_gitlab/vars.rb
terraspace_ci_gitlab-0.1.0 lib/terraspace_ci_gitlab/vars.rb