我试图创建一个詹金斯管道通过詹金斯文件与共享库。我通过Web UI创建了一个作业来获取Jenkinsfile,它工作正常。然而,詹金斯似乎无法识别共享库内容。下面是Jenkinsfile和共享库内容以及控制台错误。我仔细检查了Jenkins常规配置(其中设置了共享库scm)和Pipeline插件安装。不知道还能去哪里。
共享库内容
# var/log.groovy
def call(String name = 'human') {
echo "Hello, ${name}."
}
詹金斯档案内容
# 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]
这应该起作用:
@Library('jenkinstest')uu新的var.log。呼叫(姓名)
将git中的var/
文件夹重命名为vars/
。在这个文件夹中,您可以存储groovy脚本。
我们正在使用JCasC使用如下定义的jenkins共享库: 我们为Kubernetes插件制作了一个方便的函数,它允许我们大大缩短代码。然而,在尝试仅消除2行时,我们遇到了一个奇怪的错误,我们希望澄清: 奇怪的是,在不改变导入或函数名称的情况下,它会显示出来。 例如,这是有效的: 但这并不是: 两者之间的所有更改是getPodTemplate是否返回podTemplate。 我们到处找了找。这个堆
我在Jenkins管道中使用下面的Groovy脚本来调用自由风格的作业,但它最终出现了“没有这样的DSL方法‘构建’”错误。
问题内容: 我在Jenkins管道中使用JSON函数并获取。我正在使用Jenkins 2.85。 任何想法如何解决这个问题? 问题答案: 使用管道实用程序步骤插件可以使用该功能。 没有此插件,您将无法使用此功能。 有关更多信息,请检查:步骤
问题内容: 我正在Linux上构建C ++可执行文件。可执行文件链接到一些Boost库中。 这是我尝试运行二进制文件时的输出: 然后,我在二进制文件上运行ldd来检查依赖关系: 我不确定为什么找不到liboos_system.sl.1.45.0 SO。我今天早些时候成功构建了它。谁能解释? 问题答案: 找不到该库。 默认情况下会在中查找库,并在中指定目录。 通常,系统库(例如boost,如果通过软
问题内容: 我正在尝试为詹金斯创建我的第一个Groovy脚本: 在这里查看https://jenkins.io/doc/book/pipeline/之后,我创建了这个: 但是,我得到: 我想念什么? 另外,如何在不以纯文本形式编写密码的情况下将我的凭据传递到Git存储库? 问题答案: 你感到困惑和混合使用,完全的差异在这里看到。但简短的故事: 声明性管道 是管道DSL的新扩展(基本上是只有一步的管
我已经安装了所有的管道插件, 但我仍在得到 我漏了什么插件吗?