Forum Discussion
Thanks Bonibom, for your reply. I have updated my script but still I am getting the following error.
Script in pipeline:
pipeline{
agent {label "windows"}
stages {
stage('Test complete'){
steps {
git credentialsId: 'GitHub-RAVEn', url: 'https://github.com/smoke-tests.git', branch: 'master'
withVault(configuration: [timeout: 60, vaultUrl: 'https://vault.com'],
vaultSecrets: [[engineVersion: 1, path: 'secret//testing',
secretValues: [[envVar: 'USERNAME', vaultKey: 'username'], [envVar: 'PASSWORD', vaultKey: 'password']]]]) {
testcompletetest commandLineArguments: "/run /SilentMode /psv:env=prod /psv:ADFSusername=${USERNAME} /psv:ADFSpassword=${PASSWORD}", generateMHT: true, launchType: 'lcProject', project: 'CORE_Prod_Smoke', suite: 'Prod_SmokeTest.pjs'
}
}
}
stage('Checking log'){
steps{
script{
List<String> log= currentBuild.rawBuild.getLog(100).contains("exit code: 0")
for (String line : log)
{
if (line.contains("Test runner exit code: 0"))
{
echo 'aborted'
emailext (
subject: "Core application Failed to login in Prod",
body: "Core application seems to be failed to login in Prod. Please click the link to access the test results for more details \n" + env.BUILD_URL+"TestComplete/",
to: 'vinod.k.tanguturi@associates.com',
from: "donotreply@cloudbees.com")
}
}
}
}
}
}
Error in console
[GitHub Checks] GitHub check (name: Jenkins, status: COMPLETED) has been published. org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method hudson.model.Run getLog int at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:265) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:161) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17) at WorkflowScript.run(WorkflowScript:18
You may need to add or approve your signatures in Manage Jenkins -> In-process Script Approval
- tvklovesu3 years agoFrequent Contributor
I think I don't have permission to do that as I am not admin. Is there any other way to achieve this without requesting my admin to approve this? Because I need to reuse the same method in multiple pipelines.
- Bonibom3 years agoContributor
Try to disable "Use Groovy Sandbox" option in your pipeline if it is enabled. If this does not work, you need to be an admin or ask your Jenkins admin to add signatures or disable script security completely.
- tvklovesu3 years agoFrequent Contributor
If I uncheck that box then I am getting a message for approving the script
So don't we have any other way to read the console output?