gpt4 book ai didi

Jenkins 共享库 : "java.lang.NoSuchMethodError: No such DSL method"

转载 作者:行者123 更新时间:2023-12-03 14:26:04 26 4
gpt4 key购买 nike

我正在尝试通过 Jenkinsfile 与共享库创建 Jenkins 管道。我通过 Web UI 创建了一个工作来获取 Jenkinsfile,它工作正常。但是,Jenkins 似乎无法识别共享库的内容。下面是 Jenkinsfile 和共享库内容以及控制台错误。我仔细检查了 Jenkins 常规配置(共享库 scm 设置的位置)和 Pipeline 插件安装。不知道还能去哪里。

共享库内容

# var/log.groovy

def call(String name = 'human') {
echo "Hello, ${name}."
}

Jenkinsfile 内容
# Jenkinsfile

@Library('jenkinstest') _

node {
log("User!")
}

日志错误
Loading library jenkinstest@master
Attempting to resolve master from remote references...
> /usr/bin/git --version # timeout=10
using GIT_SSH to set credentials Gitlab ssh key
> /usr/bin/git ls-remote -h -t #############/jenkinstest.git # timeout=10
Found match: refs/heads/master revision #############
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
Fetching without tags
Fetching upstream changes from git@##############/jenkinstest.git
> /usr/bin/git --version # timeout=10
using GIT_SSH to set credentials Gitlab ssh key
> /usr/bin/git fetch --no-tags --progress git@##############/jenkinstest.git +refs/heads/*:refs/remotes/origin/*
Checking out Revision ############# (master)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f #############
Commit message: "fix on groovy"
> /usr/bin/git rev-list --no-walk ############# # timeout=10
[Pipeline] node
Running on jenkins-node3 in /Users/admin/jenkins-home/workspace/automation-pipeline
[Pipeline] {
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'log' found among steps [acceptGitLabMR, addGitLabMRComment, ansiColor, archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, gitlabBuilds, gitlabCommitStatus, input, isUnix, jiraComment, jiraIssueSelector, jiraSearch, junit, library, libraryResource, load, mail, milestone, node, parallel, powershell, properties, publishHTML, pwd, readFile, readTrusted, resolveScm, retry, script, sh, slackSend, sleep, sshagent, stage, stash, step, svn, task, throttle, timeout, timestamps, tm, tool, unarchive, unstash, updateGitlabCommitStatus, validateDeclarativePipeline, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, allOf, always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, architecture, archiveArtifacts, artifactManager, authorizationMatrix, batchFile, bitbucket, booleanParam, branch, buildButton, buildDiscarder, buildParameter, caseInsensitive, caseSensitive, certificate, changelog, changeset, choice, choiceParam, cleanWs, clock, cloud, command, compressBuildLog, configFile, configFileProvider, copyArtifacts, credentials, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerCert, dockerfile, downloadSettings, downstream, dumb, envVars, environment, expression, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, fromScm, fromSource, git, gitLabConnection, github, githubPush, gitlab, gradle, headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, inheriting, inheritingGlobal, installSource, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobName, label, lastCompleted, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, lastSuccessful, latestSavedBuild, legacy, legacySCM, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, myView, node, nodeProperties, nonInheriting, nonStoredPasswordParam, none, not, nunit, overrideIndexTriggers, paneStatus, parameterizedCron, parameters, password, pattern, permalink, pipeline-model, pipelineTriggers, plainText, plugin, pollSCM, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, remotingCLI, run, runParam, schedule, scmRetryCount, search, security, shell, skipDefaultCheckout, skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter, specific, sshUserPrivateKey, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, usernameColonPassword, usernamePassword, viewsTabBar, weather, withAnt, workspace, zfs, zip] or globals [currentBuild, docker, env, manager, params, pipeline, scm]

最佳答案

重命名您的 var/ git 中的文件夹到 vars/ .在此文件夹中,您可以存储您的 groovy 脚本。

关于 Jenkins 共享库 : "java.lang.NoSuchMethodError: No such DSL method",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48175977/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com