Hello, I am trying to create a job using the job dsl.
My code is present in github. I have created the admin-seedjob pipeline and the definition of the pipeline is as follows :-
Definition :- Pipeline script from SCM
REPO USR -: XYZ.github.com/.../....git
Script Path :- PATH TO MY Script :-
def gitUrl = “GitHub - kjaindevops/jenkins-jobs-group: Jenkins Job DSL scripts to create jobs and views”
def jobDslScript = “pipelines/group/functions_terraform/fms_pipelines_rnd_seedjob.groovy”
pipelineJob(‘Folder1/Folder2/Folder-3/NAME’) {
description(‘Pipeline job for validating new groovy jobs’)
logRotator(30,100)
parameters{
choiceParam(‘gitUrl’, [gitUrl], ‘Jenkins Git URL for Terraform repo’)
choiceParam(‘gitBranchType’, [‘feature’, ‘main’])
stringParam(‘gitBranchName’, ‘’, ‘Leave blank for Main branch’)
choiceParam(‘dslScriptDirectory’,
[
‘functions_terraform’
], ‘select directory where your pipeline definition is located:
it will pick up all the definition macthing patter: jobs/nonprod/group[dslScriptDirectory]/**/*.groovy
Job will reload pipelines using definition from selected branch.’)
stringParam(‘dslScriptfilename’, ‘’, ‘OPTIONAL If you want to refresh just one job select directory and provide file name including extension, leave blank for whole directory
jobs/nonprod/group/[dslScriptfile]/[dslScriptfilename]’)
}
definition {
cps {
script(readFileFromWorkspace(jobDslScript))
sandbox()
}
}
}
But when i am running the jenkins pipeline its throwin me the below error :-
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 08813415-cfe5-4ead-a03e-b1f65c9f1192
java.lang.NoSuchMethodError: No such DSL method ‘pipelineJob’ found among steps [archive, bat, build, catchError, checkout, compareVersions, deleteDir, dir, ec2, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, findBuildScans, findFiles, getContext, git, input, isUnix, junit, library, libraryResource, load, mail, milestone, node, nodesByLabel, parallel, powershell, prependToFile, properties, publishChecks, pwd, pwsh, readCSV, readFile, readJSON, readManifest, readMavenPom, readProperties, readTrusted, readYaml, resolveScm, retry, script, setGitHubPullRequestStatus, sh, sha1, sha256, sleep, stage, stash, step, tar, task, tee, timeout, timestamps, tm, tool, touch, unarchive, unstable, unstash, untar, unzip, validateDeclarativePipeline, verifySha1, verifySha256, waitForBuild, waitUntil, warnError, withChecks, withContext, withCredentials, withEnv, withGradle, withGroovy, wrap, writeCSV, writeFile, writeJSON, writeMavenPom, writeYaml, ws, zip] or symbols [GenericTrigger, GitUsernamePassword, Number, Open, agent, all, allBranchesSame, allOf, allowRunOnStatus, always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, apiTokenProperty, architecture, archiveArtifacts, artifactManager, asIsGITScm, assembla, authorInChangelog, authorizationMatrix, aws, batchFile, bitbucket, bitbucketServer, booleanParam, branch, branchCreated, branches, brokenBuildSuspects, brokenTestsSuspects, browser, buildButton, buildDiscarder, buildDiscarders, buildRetention, buildSingleRevisionOnly, buildUser, buildingTag, builtInNode, caseInsensitive, caseSensitive, certificate, cgit, changeRequest, changelog, changelogBase, changelogToBranch, changeset, checkoutOption, checkoutToSubdirectory, choice
But when i am simply creating a freestyle project and under the job dsl script i am giving
pipelineJob(‘example’) {
description(‘Test’)
}
Its creating the pipeline.
I have all the required plugins installed.
Jenkins version :- [Jenkins 2.401.1]