Sha256: 6677f673f014cc6901afe6ee1cd9de3c526ff965bcad84760b70baddf41ff07f

Contents?: true

Size: 767 Bytes

Versions: 12

Compression:

Stored size: 767 Bytes

Contents

$is_mac = `uname`.chomp == 'Darwin'
require 'security' if $is_mac

module Jenkins
  module Builder
    class Secret

      SERVICE = 'jenkins-builder-credentials'

      attr_accessor :username, :password

      def initialize
        if credentials = load
          @username = credentials[:username]
          @password = credentials[:password]
        end
      end

      def load
        if result = Security::GenericPassword.find(service: SERVICE)
          {username: result.attributes['acct'], password: result.password}
        end
      end

      def save!
        delete
        Security::GenericPassword.add(SERVICE, @username, @password)
      end

      def delete
        Security::GenericPassword.delete(service: SERVICE)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
jenkins-builder-0.3.4 lib/jenkins/builder/secret.rb
jenkins-builder-0.3.3 lib/jenkins/builder/secret.rb
jenkins-builder-0.3.2 lib/jenkins/builder/secret.rb
jenkins-builder-0.3.1 lib/jenkins/builder/secret.rb
jenkins-builder-0.3.0 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.6 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.5 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.4 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.3 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.2 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.1 lib/jenkins/builder/secret.rb
jenkins-builder-0.2.0 lib/jenkins/builder/secret.rb