[英]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.