Advertisement
Guest User

Untitled

a guest
May 9th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. $LOAD_PATH.push File.expand_path("spaceship/lib")
  3. require "spaceship"
  4. require "date"
  5. require 'rubygems'
  6. require 'dogapi'
  7.  
  8. # this application requiers fastlane installed and sapceship working.
  9. # in addition please install datadig api for ruby
  10.  
  11. # Datadog api keys
  12. api_key = API_KEY
  13. application_key = APPLICATION_KEY
  14.  
  15. max_days = 30 # maximum day before alerting
  16. user = APPLE_ACCOUNT
  17. password = APPLE_ACCOUNT_PASSWORD
  18.  
  19. # Create a statsd client instance.
  20. dog = Dogapi::Client.new(api_key, application_key)
  21.  
  22. # Log in to apple developer console
  23. Spaceship::Portal.login(user, password)
  24. # for eatch team write the name of the team the the certificate that will expires in $max_days
  25. teams = Spaceship::Portal.client.teams
  26. teams.each do |team|
  27. puts "#############"
  28. print "team: #{team['name']}\n"
  29. Spaceship::Portal.client.team_id = team['teamId']
  30. certificates = Spaceship::Portal.certificate.all
  31. certificates.each do |elem|
  32. name = elem.raw_data["certificate"]['name']
  33. date = Date.parse elem.raw_data["certificate"]['expirationDate']
  34. if date <= Date.today + max_days
  35. expiresin = date - Date.today
  36. dog.emit_point('apple.certificate.expires_in', expiresin, :tags => ["Name:#{name}"])
  37. print "#{name} expires in #{expiresin} days\n"
  38. end
  39. end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement