I’m very new to Jenkins – I’m making an attempt to run a multibranch pipeline script on Jenkins model 2.375.1. The builds are triggered with commits and PR’s filed on Github. On committing a brand new file or initiating a PR, Jenkins auto triggers a construct however persistently stops because it hits this challenge.
org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
Script1.groovy: 1: sudden char: '' @ line 1, column 2.
{rtf1ansiansicpg1252cocoartf2513
I’ve added a Jenkinsfile.Jenkinsfile and Instance.groovy script in my repo with this code ->
Jenkinsfile.Jenkinsfile (notice the .Jenkinsfile extension is hidden within the repo)
node {
// Git checkout earlier than load supply the file
checkout scm
// To know recordsdata are checked out or not
sh '''
ls -lhrt
'''
def rootDir = pwd()
println("Present Listing: " + rootDir)
// level to actual supply file
def instance = load "${rootDir}/Instance.Groovy"
instance.exampleMethod()
instance.otherExampleMethod()
}
Instance.groovy (Notice the .groovy extension is hidden in repo)
import hudson.slaves.EnvironmentVariablesNodeProperty
import hudson.EnvVars
import jenkins.mannequin.*
jenkins = Jenkins.occasion
EnvironmentVariablesNodeProperty prop = jenkins.getGlobalNodeProperties().get(EnvironmentVariablesNodeProperty.class)
EnvVars env = prop.getEnvVars()
def MY_VAR = env['MY_JENKINS_VAR']
def exampleMethod() {
println("exampleMethod")
}
def otherExampleMethod() {
println("otherExampleMethod")
}
return this