0
votes

I have followed this link https://github.com/JFrogDev/project-examples/blob/master/jenkins-pipeline-examples/maven-example/Jenkinsfile to get the buildInfo in jenkins pipeline script.Here I just need buildDependencies for Fortify Scan(need to scan both dependencies and soucre code).Here is the code snippet.

def buildInfo = Artifactory.newBuildInfo()
buildInfo = rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean install', buildInfo: buildInfo

println buildInfo.getName()
println buildInfo.getNumber()

Im able to get the Build Name and Build Number,but when I try to call getBuildDependencies() its giving error Scripts are not permitted to use method org.jfrog.hudson.pipeline.types.buildinfo.BuildInfo getBuilfDependencies()

buildInfo.getBuildDependencies().each{ dependency ->
println dependency.getName() 
}

Why im not able to get dependencies from buildInfo where as im getting values for build name and build number..can someone help me out to get sorted this problem...Thanks for your help in Advance.

1

1 Answers

1
votes

You should got to Manage Jenkins -> In-process Script Approval, find signature of getBuilfDependencies() method and click Approve to approve it. See In-process Script Approval for more information.
Also depending on version of Jenkins pipeline that you use each{} method may not work properly (JENKINS-26481, JENKINS-27421). If your version of Jenkins has those issues try to use old-style for loop or wrap iteration in @NonCPS method.