0
I have tried the following to get a commit sha of a specific build. 
But Jenkins showed a security error. Is there a possible way to achieve this?

import hudson.model.*

def jenkins_job_name = "Some Job"
def build_number = 46
def jenkins_job = Hudson.instance.getItem(jenkins_job_name)

def getBuild = jenkins_job.getBuildByNumber(build_number)

def commit_sha = getBuild.getEnvironment().get('GIT_COMMIT')

*Scripts not permitted to use method hudson.model.Run getEnvironment. Administrators can decide whether to approve or reject this signature.*
Abhinay Reddy Keesara
  • 9,763
  • 2
  • 18
  • 28

0 Answers0