[英]Jenkins to Bamboo Migration & Running Groovy
我对 Jenkins 和 Bamboo 完全是新手。 我有一个 Jenkins 管道,我正在尝试在 Bamboo 中创建一个等价物(我相信它被称为计划)。
我有一些 groovy 代码要在我的 Bamboo 计划中运行。
为了简洁明了,我将简化下面的代码。
假设此文件名为me_myEvent.groovy
并存储在https://github.com/myuser/repo1
def processEvent( Map args ) {
String strArg1 = args.myArg1;
String strArg2 = args.myArg2;
// etc...
}
我的 Jenkins 管道有一个全局管道库( myGitLibraryFromGlobal
)链接到https://github.com/myuser/repo1
我的管道是:
@Library('myGitLibraryFromGlobal@master') abc
pipeline {
agent any
stages {
stage('First Stage') {
steps {
script {
def myObj = new com.mysite.me_myEvent();
def returnVal = myObj.processEvent(arg1: 'foo', arg2: 'bar');
}
}
})
}
}
我将 GitHub 存储库保存在 Bamboo 中,作为名为abc123
的全局链接存储库。
我可以使用script
任务在 Bamboo 中实现相同的功能吗? 这在 Bamboo 中会是什么样子?
简短的回答是NO ,因为 Atlassian Bamboo 不支持DSL Groovy 或 Scripted Groovy 管道。 Also, please keep in mind that when you run the Jenkins Groovy pipeline, then Jenkins adds its own environment to the script execution, it is not just running "bare" groove script (ie without exposed Jenkins commands and variables).
如果您需要运行支持Configuration as Code思想的“裸” groovy 脚本,一种解决方案是创建Bamboo Java/YAML 规范。 然后你需要创建ScriptTask 。
// this is called when the plan and stages are created
new Job("JobName","JobKey").tasks(new VcsCheckoutTask(), // to download the groovy script
new ScriptTask().inlineBody("groovy me_myEvent.groovy").interpreterBinSh())
注意:您的Bamboo 构建代理应预先安装 groovy。
另一种解决方案是使用 Bamboo 插件Groovy Tasks for Bamboo 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.