Sha256: 41649ddde29477b3778b46a9374a6600e3962a2c6d546af685aaa743865876de

Contents?: true

Size: 720 Bytes

Versions: 7

Compression:

Stored size: 720 Bytes

Contents

require 'security'

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

7 entries across 7 versions & 1 rubygems

Version Path
jenkins-builder-0.1.6 lib/jenkins/builder/secret.rb
jenkins-builder-0.1.5 lib/jenkins/builder/secret.rb
jenkins-builder-0.1.4 lib/jenkins/builder/secret.rb
jenkins-builder-0.1.3 lib/jenkins/builder/secret.rb
jenkins-builder-0.1.2 lib/jenkins/builder/secret.rb
jenkins-builder-0.1.1 lib/jenkins/builder/secret.rb
jenkins-builder-0.1.0 lib/jenkins/builder/secret.rb