jenkinsjenkins-pipelinejenkins-pluginscicdjenkins-job-dsl

NoSuchMethodError: No such DSL method 'inline'


I'm trying to integrate Jenkins to a GCP Instance Group. To do so, I'm told I must run this pipeline script (parameters omitted).

pipeline {
  agent any
  stages {
    stage('Triger CloudBuild..') {
      steps {
        googleCloudBuild credentialsId: '<ENTER-YOUR-CREDS-ID>' , request: inline('''steps:
        # Creating a golden image
        - name: gcr.io/cloud-builders/gcloud
          id: create-golden-image
          args:
          - beta
          - compute
          - images
          - create                                                                                 
          - <ENTER-NEW-IMAGE-NAME>
          - --source-disk=<ENTER-YOUR-VM-SOURCEDISK-NAME>
          - --source-disk-zone=<ENTER-YOUR-SOURCE-DISK-ZONE>
          - --project=<ENTER-YOUR-PROJECT-ID>
          - --force
        #Creating a new instance template
        - name: gcr.io/cloud-builders/gcloud
          id: create-instance-template
          args:
          - beta
          - compute
          - instance-templates
          - create
          - <ENTER-YOUR-NEW-TEMPLATE-NAME>
          - --subnet=projects/<ENTER-YOUR-PROJECT-ID>/regions/<ENTER-YOUR-REGION-NAME>/subnetworks/<ENTER-YOUR-SUBNET-NAME>
          - --no-address
          - --image-project=<ENTER-YOUR-PROJECT-ID>
          - --maintenance-policy=MIGRATE
          - --service-account=<ENTER-YOUR-SERVICE-ACCOUNT-NAME>
          - --scopes=https://www.googleapis.com/auth/cloud-platform
          - --region=<ENTER-REGION-NAME>
          - --tags=mig-rolling-update
          - --image=<ENTER-NEW-IMAGE-NAME>
          - --boot-disk-size=<ENTER-BOOT-DISK-SIZE>
          - --boot-disk-type=<ENTER-DISK-SIZE>
          - --boot-disk-device-name=<ENTER-BOOT-DISK-NAME>
          - --project=<ENTER-YOUR-PROJECT-ID>
        #Make sure that our MIG is stable before update
        - name: gcr.io/cloud-builders/gcloud
          id: wait-until-stable
          args:
          - beta
          - compute
          - instance-groups
          - managed
          - wait-until
          - <ENTER-YOUR-MIG-NAME>
          - --stable
          - --project=<ENTER-YOUR-PROJECT-ID>
          - --zone=<ENTER-YOUR-ZONE-NAME>
        #Updating the MIG with new instance template
        - name: gcr.io/cloud-builders/gcloud
          id: updating-mig
          args:
          - beta
          - compute
          - instance-groups
          - managed
          - rolling-action
          - start-update
          - <ENTER-YOUR-MIG-NAME>
          - --version=template=<ENTER-YOUR-TEMPLATE-NAME>
          - --type=proactive
          - --zone=<ENTER-YOUR-ZONE-NAME>
          - --project=<ENTER-YOUR-PROJECT-ID>''')
      }
    }
  }
}

However, I get the following error:

java.lang.NoSuchMethodError: No such DSL method 'inline' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, downstreamBuilds, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, findBuildScans, getContext, git, input, isUnix, junit, library, libraryResource, load, lock, mail, milestone, node, parallel, powershell, properties, publishChecks, publishHTML, pwd, pwsh, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, timeout, timestamps, tm, tool, unarchive, unstable, unstash, validateDeclarativePipeline, waitForBuild, waitUntil, warnError, withChecks, withContext, withCredentials, withEnv, withGradle, wrap, writeFile, ws] or symbols [GitUsernamePassword, agent, all, allBranchesSame, allOf, always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, apiTokenProperty, architecture, archiveArtifacts, artifactManager, assembla, authorInChangelog, authorizationMatrix, batchFile, bitbucket, bitbucketServer, booleanParam, branch, brokenBuildSuspects, brokenTestsSuspects, browser, buildButton, buildDiscarder, buildDiscarders, buildRetention, buildSingleRevisionOnly, buildUser, buildingTag, builtInNode, caseInsensitive, caseSensitive, certificate, cgit, changeRequest, changelog, changelogBase, changelogToBranch, changeset, checkoutOption, checkoutToSubdirectory, choice, choiceParam, cleanAfterCheckout, cleanBeforeCheckout, cleanWs, clock, cloneOption, command, contributor, credentials, cron, crumb, culprits, defaultDisplayUrlProvider, defaultFolderConfiguration, defaultView, demand, developers, disableConcurrentBuilds, disableRestartFromStage, disableResume, discoverOtherRefs, discoverOtherRefsTrait, downstream, dumb, durabilityHint, email-ext, envVars, envVarsFilter, environment, equals, experimentalFlags, expression, extendedEmailPublisher, file, fileParam, filePath, fingerprint, fingerprints, fisheye, frameOptions, freeStyle, freeStyleJob, fromScm, fromSource, git, gitBranchDiscovery, gitHooks, gitHubBranchDiscovery, gitHubBranchHeadAuthority, gitHubExcludeArchivedRepositories, gitHubExcludeForkedRepositories, gitHubExcludePrivateRepositories, gitHubExcludePublicRepositories, gitHubForkDiscovery, gitHubIgnoreDraftPullRequestFilter, gitHubPullRequestDiscovery, gitHubSshCheckout, gitHubTagDiscovery, gitHubTopicsFilter, gitHubTrustContributors, gitHubTrustEveryone, gitHubTrustNobody, gitHubTrustPermissions, gitLab, gitList, gitSCM, gitTagDiscovery, gitTool, gitUsernamePassword, gitWeb, gitblit, github, githubProjectProperty, githubPush, gitiles, gogs, gradle, group, headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, ignoreOnPush, inbound, inheriting, inheritingGlobal, installSource, isRestartedRun, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobBuildDiscarder, jobName, junitTestResultStorage, kiln, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, lfs, list, local, localBranch, localBranchTrait, locale, location, logRotator, loggedInUsersCanDoAnything, mailer, masterBuild, maven, maven3Mojos, mavenErrors, mavenGlobalConfig, mavenMojos, mavenWarnings, modernSCM, multiBranchProjectDisplayNaming, multibranch, myView, namedBranchesDifferent, node, nodeProperties, nonInheriting, none, nonresumable, not, organizationFolder, overrideIndexTriggers, paneStatus, parallelsAlwaysFailFast, parameters, password, pattern, perBuildTag, permanent, phabricator, pipeline, pipelineTriggers, plainText, plugin, pollSCM, preserveStashes, previous, priorityStrategy, projectNamingStrategy, proxy, pruneStaleBranch, pruneStaleTag, pruneTags, queueItemAuthenticator, quietPeriod, rateLimit, rateLimitBuilds, recipients, redmine, refSpecs, remoteName, requestor, resourceRoot, retainOnlyVariables, rhodeCode, run, runParam, sSHLauncher, schedule, scmGit, scmRetryCount, scriptApproval, scriptApprovalLink, search, security, shell, simpleBuildDiscarder, skipDefaultCheckout, skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter, sparseCheckoutPaths, ssh, sshPublicKey, sshUserPrivateKey, standard, status, strict, string, stringParam, submodule, submoduleOption, suppressAutomaticTriggering, suppressFolderAutomaticTriggering, swapSpace, tag, teamFoundation, teamSlugFilter, text, textParam, timestamper, timestamperConfig, timezone, tmpSpace, toolLocation, triggeredBy, unsecured, untrusted, upstream, upstreamDevelopers, user, userIdentity, userOrGroup, userSeed, usernameColonPassword, usernamePassword, viewgit, viewsTabBar, weather, withAnt, zip] or globals [currentBuild, env, params, pipeline, scm]

I thought maybe installing the Multibranch Pipeline Inline Definition Plugin would solve the issue, but it did not. Any ideas?


Solution

  • Rahul Sharma figured it out. It is necessary to install the "Google Cloud Build" "Google Deployment Manager Jenkins" plugins in order to get the 'inline' method.