为什么 Jenkins 缓存我旧的损坏的 Jenkinsfile?



我已经推送了几个更新,这些更新实际上显示在 jenkins 中的更改中,但是当第一个 Jenkinsfile 导致错误时,错误仍然显示相同的错误消息。

例:

Started by an SCM change
Obtained Jenkinsfile from git git@bitbucket[myserver]/jenkins_docker.git
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 2: Expected an agent @ line 2, column 3.
agent {
^
WorkflowScript: 2: No agent type specified. Must be one of [any, docker, dockerfile, label, none] @ line 2, column 3.
agent {
^
2 errors
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)

我的 jenkinsfile 现在更新为如下所示:

pipeline {
agent {
label: 'nodejs10'
}
stages {
stage('Test') {
steps {
echo 'Testing...'
}
}
}
}

好吧,它不是缓存。我意识到了自己的错误。

  1. 我安装了 nodejs 插件,但我没有在 nodejs 插件的全局工具配置中配置 node10:

    • https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin
  2. 我也说错了。我现在已经将代理更改为"any",并按照此项目上的说明进行操作,如下所示:

    • https://medium.com/@gustavo.guss/jenkins-starting-with-pipeline-doing-a-node-js-test-72c6057b67d4
pipeline {
agent any
tools {nodejs "nodejs10"}
// stuff here...
}

这行得通。虽然我现在对 npm 没有安装有一个不同的问题,但现在在一个单独的问题中。

最新更新