У меня есть простой JenkinsFile, загруженный в мое git репо
pipeline {
agent any
stages {
stage('Initialize'){
def dockerHome = tool 'myDocker'
env.PATH = "${dockerHome}/bin:${env.PATH}"
}
stage('Push to Docker Registry'){
withCredentials([usernamePassword(credentialsId: 'dockerHubAccount', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD)
}
}
}
}
В jenkins я создал проект конвейера и только что прошел путь к моему git репо. my Docker определен в глобальной конфигурации инструмента. Учетные данные dockerhub определены в jenkins-> credentials.
При сборке я получаю следующее:
Started by user ********
Obtained Jenkinsfile from git https://github.com/*****/*****.git
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 4: Not a valid stage section definition: "def dockerHome = tool 'myDocker'". Some extra configuration is required. @ line 4, column 9.
stage('Initialize'){
^
WorkflowScript: 4: Not a valid stage section definition: "env.PATH = "${dockerHome}/bin:${env.PATH}"". Some extra configuration is required. @ line 4, column 9.
stage('Initialize'){
^
WorkflowScript: 8: Unknown stage section "withCredentials". Starting with version 0.5, steps in a stage must be in a ‘steps’ block. @ line 8, column 9.
stage('Push to Docker Registry'){
^
WorkflowScript: 4: Expected one of "steps", "stages", or "parallel" for stage "Initialize" @ line 4, column 9.
stage('Initialize'){
^
WorkflowScript: 8: Expected one of "steps", "stages", or "parallel" for stage "Push to Docker Registry" @ line 8, column 9.
stage('Push to Docker Registry'){
^
5 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)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
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:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
Finished: FAILURE
Я уверен, я делаю любую небольшую ошибку. Пожалуйста, перенаправьте меня в правильном направлении.