Ở các bài trước thì bạn sẽ thấy script pipeline của mình khá là dài.
Bài này script pipeline siêu ngắn.
@Library("pipeline-shared-lib") _
execBuildOrDeploy("build")
Bạn sẽ thấy là script sẽ thấy call global function execBuildOrDeploy()
https://github.com/mrnim94/pipeline-shared-lib/blob/master/vars/execBuildOrDeploy.groovy
Chúng ta sẽ định nghĩ pipeline Script trong method Call
def call(String command) {
if (command == "build")
{
pipeline {
agent any
stages
{
stage("Build")
{
steps
{
echo "Build is executed"
}
}
}
}
}
else if(command == "deploy")
{
pipeline {
agent any
stages
{
stage("Deploy")
{
steps
{
echo "Deploy is executed"
}
}
}
}
}
else
{
pipeline {
agent any
stages
{
stage("Do Nothing")
{
steps
{
echo "Doing nothing"
}
}
}
}
}
}
Save lại và coi thành phả nào