我是Jenkins pipline的新手,我试图在检查我的github仓库的Master分支后得到git SHA,但我找不到正确的方法来做...
我的代码:
pipeline {
agent { label 'SonarPHP56' }
stages {
stage('vehicle-prices.com') {
agent { label 'SonarPHP70' }
steps {
//vehicle-prices.com
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'st-jenkins-bot', url: 'https://github.com/****/vehicle-prices.com']]]
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
sh 'echo ${gitCommit}'
}
}
}
}
我正在尝试使用此行:
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
sh 'echo ${gitCommit}'
但是我从Jenkins控制台得到了这个:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 24: Expected a step @ line 24, column 17.
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:129)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:123)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:516)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:479)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:252)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE
有人能帮助我吗?