我必須使用wget命令發送請求。 下面我原來的shell腳本:如何在Jenkins管道腳本中使用帶有幾個參數的wget
wget的--post數據 「PARAMS = $ PARAMS & URI = $ URI &專案編號= $專案編號& suiteId = $ suiteId &的runid = $ runid爲& projectNameValue = $ projectNameValue & caseIdStart = $ caseIdStart & caseIdEnd = $ caseIdEnd & mockFlag = $ mockFlag」 http://10.139.11.150:9999/SEAutoTest2/testrun/testrail
這個wget命令反式將幾個參數移植到一個頁面上。 我使用管道語法來實現管道代碼,但它不起作用。 參數無法從字符串參數中實現。
這是我的jenkins configration截圖。
這裏是我的流水線代碼:
node('dev_ci_env_migu') {
properties([parameters([string(defaultValue: ' ', description: ' ', name: 'VERSION'), string(defaultValue: ' ', description: ' ', name: 'SVN_ADDRESS'), string(defaultValue: ' ', description: ' ', name: 'TEST_ENV'), string(defaultValue: ' ', description: ' ', name: 'USER'), string(defaultValue: ' ', description: ' ', name: 'PASSWD'), string(defaultValue: ' ', description: ' ', name: 'PACKAGE_PATH'), string(description: '', name: 'params'), string(defaultValue: ' ', description: ' ', name: 'projectNameValue'), string(defaultValue: ' ', description: ' ', name: 'uri'), string(defaultValue: ' ', description: ' ', name: 'projectId'), string(defaultValue: ' ', description: ' ', name: 'suiteId'), string(defaultValue: ' ', description: ' ', name: 'runId'), string(defaultValue: ' ', description: ' ', name: 'caseIdStart'), string(defaultValue: ' ', description: ' ', name: 'caseIdEnd'), string(defaultValue: ' ', description: ' ', name: 'mockFlag')]), pipelineTriggers([])])
withEnv(['INTERNAL_PATH=/data/path']) {
//get code from svn
stage 'Checkout'
checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: '', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: '$SVN_ADDRESS']], workspaceUpdater: [$class: 'UpdateUpdater']])
//compile & generate war
stage 'Build'
sh '''source /home/migu/.bashrc
cd $WORKSPACE
mvn clean install -DskipTests'''
stage('Automation Test'){
input 'Is test automation preparation job done?'
sh 'wget --post-data 'params=${params}&uri=${uri}&projectId=${projectId}&suiteId=${suiteId}&runId=${runId}&projectNameValue=${projectNameValue}&caseIdStart=${caseIdStart}&caseIdEnd=${caseIdEnd}&mockFlag=${mockFlag}\' http://10.139.11.150:9999/SEAutoTest2/testrun/testrail'
}
}
}
感謝您解決這困擾了我很久的問題。我使用你的建議,它終於有效。 – Jill