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) + } +}