From 7bb1ede2dff92c041fe6765803d1f6daa01d814c Mon Sep 17 00:00:00 2001 From: Thomas Papendieck Date: Wed, 30 Jan 2019 10:52:49 +0100 Subject: [PATCH] Jenkinsfile added --- src/main/script/Jenkinsfile-2.groovy | 3 +++ src/main/script/Jenkinsfile.groovy | 31 ++++++++++++++++++++++++++++ src/main/script/PipelineStep.groovy | 5 +++++ vars/PipeLineStepTest.groovy | 5 +++++ vars/testBuildFileName.groovy | 6 ++++++ 5 files changed, 50 insertions(+) create mode 100644 src/main/script/Jenkinsfile-2.groovy create mode 100644 src/main/script/Jenkinsfile.groovy create mode 100644 src/main/script/PipelineStep.groovy create mode 100644 vars/PipeLineStepTest.groovy create mode 100644 vars/testBuildFileName.groovy diff --git a/src/main/script/Jenkinsfile-2.groovy b/src/main/script/Jenkinsfile-2.groovy new file mode 100644 index 0000000..16aa471 --- /dev/null +++ b/src/main/script/Jenkinsfile-2.groovy @@ -0,0 +1,3 @@ +library identifier:'jenkinsfileExample@current', retriever:legacySCM(scm) + +testBuildFileName() diff --git a/src/main/script/Jenkinsfile.groovy b/src/main/script/Jenkinsfile.groovy new file mode 100644 index 0000000..37ad681 --- /dev/null +++ b/src/main/script/Jenkinsfile.groovy @@ -0,0 +1,31 @@ +pipeline { + agent any + tools { + maven 'maven-3.6.0' + } + + stages { + stage("SCM checkout"){ + steps{ + echo "BRANCH_NAME: ${env.BRANCH_NAME}" + checkout scm + } + } + stage("branch processing"){ + steps{ + echo "BRANCH_NAME: ${env.BRANCH_NAME}" + script { + if (env.BRANCH_NAME.startsWith("feature")) { + echo "rebase ${env.BRANCH_NAME} on develop" + } + } + } + } + stage("maven build"){ + steps{ + sh '''mvn clean install''' + } + } + } + +} diff --git a/src/main/script/PipelineStep.groovy b/src/main/script/PipelineStep.groovy new file mode 100644 index 0000000..9972c03 --- /dev/null +++ b/src/main/script/PipelineStep.groovy @@ -0,0 +1,5 @@ +class PipelineStep{ + def run(script){ + println( "inside class") + } +} diff --git a/vars/PipeLineStepTest.groovy b/vars/PipeLineStepTest.groovy new file mode 100644 index 0000000..e3e78be --- /dev/null +++ b/vars/PipeLineStepTest.groovy @@ -0,0 +1,5 @@ +class PipeLineStepTest{ + def run(script, env){ + script.echo "second test" + } +} diff --git a/vars/testBuildFileName.groovy b/vars/testBuildFileName.groovy new file mode 100644 index 0000000..185dc86 --- /dev/null +++ b/vars/testBuildFileName.groovy @@ -0,0 +1,6 @@ +def call(){ + node { + echo "test" + new PipeLineStepTest().run(this, env) + } +}