Dear community,
I have read in several posts that it should be possible to move a complete pipeline to a dynamic library. I have followed the examples and tried the following
Pipeline:
@Library(‘build-tools’) _
def _node = ‘macos’
def _workspace = ‘/users/jenkins/workspace/plugins/xyz’
def _repo = ‘http://x.x.x.x/svn/plugins/xyz/trunk’
def _artifacts = ‘build/xyz.*’pipeProject(workspace: “{_workspace}", target: "{_node}”, repo: “{_repo}", type: "mac", artifacts: "{_artifacts}”)
Groovy file pipeProject:
call(Map param=[:]) {
pipeline {
agent {
node {
label “{param.node}" customWorkspace "{param.workspace}”
}
}
stages {
stage (‘Checkout’) {
steps {
script {
checkoutProject(remote: “${param.repo}”, clean: true)
}
When starting the pipeline i get the following error
[Pipeline] Start of Pipeline
[Pipeline] End of Pipeline
org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
C:\ProgramData\Jenkins.jenkins\jobs\xyz\builds\8\libs\vars\pipeProject.groovy: 2: pipeline block must be at the top-level, not within another block. @ line 2, column 5.
pipeline {
^
1 error
Any idea why this error occurs?
Since all pipelines in our company are almost the same and only differ in the parameters, I would like to outsource this centrally.
Thanks in advance and many greetings
Arne