title: Sidekiq retry count in job
body: <p>Is there a way to get the retry count for the current job?</p>
  
  <p>I want the job to stop, not crash, after x retries. I would like to ask the retry count in the perform method so I could simply return if the retry count equals x.</p>
  
  <pre><code>def perform(args)
    return if retry_count &gt; 5
    ...
  end
  </code></pre>
  
  <p>Using Sidekiq 2.12.</p>
  
  <h2>Edit</h2>
  
  <p>I (not the OP) have the same question but for a different reason. If the job is being retried I want to do additional sanity checking to make sure the job is needed and to quit retrying if it is no longer expected to succeed because something external changed since it was queued. </p>
  
  <p>So, is there a way to get the retry count for the current job? The current answers only suggest ways you can get around needing it or can get it from outside the job.</p>