lib/danger/ci_source/jenkins.rb in danger-5.5.9 vs lib/danger/ci_source/jenkins.rb in danger-5.5.10

- old
+ new

@@ -45,10 +45,16 @@ # # #### GitLab # As you own the machine, it's up to you to add the environment variable for the `DANGER_GITLAB_API_TOKEN`. # class Jenkins < CI + class EnvNotFound < StandardError + def initialize + super("ENV not found, please check your Jenkins. Related: https://stackoverflow.com/search?q=jenkins+env+null") + end + end + def self.validates_as_ci?(env) env.key? "JENKINS_URL" end def self.validates_as_pr?(env) @@ -66,9 +72,11 @@ ] end end def initialize(env) + raise EnvNotFound.new if env.nil? || env.empty? + self.repo_url = self.class.repo_url(env) self.pull_request_id = self.class.pull_request_id(env) repo_matches = self.repo_url.match(%r{(?:[\/:])projects\/([^\/.]+)\/repos\/([^\/.]+)}) # Bitbucket Server if repo_matches