任何人都可以解釋爲什麼我會得到以下錯誤,什麼可能是他們的可能的解決方案?Jenkinsfile管道錯誤:「預期的符號」和「未定義的部分」
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 20: Expected a symbol @ line 20, column 4. environment {
WorkflowScript: 17: Undefined section "error" @ line 17, column 1.
pipeline {
在Jenkinsfile的代碼如下:
#!groovy
def application, manifest, git, environment, artifactory, sonar
fileLoader.withGit('[email protected]<reducted>', 'v1', 'ssh-key-credential-id-number') {
application = fileLoader.load('<reducted>');
manifest = fileLoader.load('<reducted>');
git = fileLoader.load('<reducted>');
environment = fileLoader.load('<reducted>');
}
pipeline {
agent { label 'cf_slave' }
environment {
def projectName = null
def githubOrg = null
def gitCommit = null
}
options {
skipDefaultCheckout()
}
stages {
stage ("Checkout SCM") {
steps {
checkout scm
script {
projectName = git.getGitRepositoryName()
githubOrg = git.getGitOrgName()
gitCommit = manifest.getGitCommit()
}
}
}
stage ("Unit tests") {
steps {
sh "./node_modules/.bin/mocha --reporter mocha-junit-reporter --reporter-options mochaFile=./testResults/results.xml"
junit allowEmptyResults: true, testResults: 'testResults/results.xml'
}
}
//stage ("SonarQube analysis") {
//...
//}
// stage("Simple deploy") {
// steps {
// // Login
// sh "cf api <reducted>"
// sh "cf login -u <reducted> -p <....>"
//
// // Deploy
// sh "cf push"
// }
// }
}
post {
// always {
// }
success {
sh "echo 'Pipeline reached the finish line!'"
// Notify in Slack
slackSend color: 'yellow', message: "Pipeline operation completed successfully. Check <reducted>"
}
failure {
sh "echo 'Pipeline failed'"
// Notify in Slack
slackSend color: 'red', message: "Pipeline operation failed!"
//Clean the execution workspace
//deleteDir()
}
unstable {
sh "echo 'Pipeline unstable :-('"
}
// changed {
// sh "echo 'Pipeline was previously failing but is now successful.'"
// }
}
}
謝謝@christopher奧爾。我是否也可以選擇你的大腦來處理Jenkins的這個問題? http://stackoverflow.com/questions/42664863/how-to-merge-a-successful-build-of-a-pull-request-using-a-jenkinsfile –
噢不錯,不知道這一個! –