共享库代码
package devopsdef Build(buildType, buildShell){def buildTools = ["mvn": "MVN", "ant": "ANT", "gradle": "GRADLE"]println("当前buildType是${buildType}")buildHome = tool buildTools[buildType]sh "${buildHome}/bin/${buildType} ${buildShell}"}
调用
@Library('jenkinslibs') _
def buidTools = new devops.build()
string buildShell = "$BUILD_SHELL"
string buildType = "$BUILD_TYPE"pipeline{agent {node {label "$CI_NODE"}}stages{stage("build"){steps{script{buildTools.Build($BUILD_TYPE, $BUILD_SHELL)}}}}
}
jenkins配置
jenkins job地址:http://192.168.24.133:8090/job/Build_CI/configure
构建工具配置