使用下面的Jenkins作业,我正在尝试从服务器删除上传
@Library('fossology-scan@feature/Abilash') _
node(label: 'si0engubudoct09') {
try {
def server_url = "https://si0engubudoct09.com:8089/repo"
def authentication_name = "FOSSOLOGY_Testing"
String filepath = readFile "/root/Abilash/upload_id.txt"
def list = filepath.collect { it }
println "list : $list"
idlist=list.split()
idlist.each { id ->
each_upload_id = id
def delete_upload_url = server_url + "/api/v1/uploads/" + each_upload_id
}
def access_token = ""
withCredentials([string(credentialsId: authentication_name, variable: 'token')]) {
access_token = token
}
def authentication = "Bearer " + access_token
stage('delete upload') {
delete_operations.delete_upload(server_url, each_upload_id, authentication)
}
}
catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
currentBuild.result = 'ABORTED'
}
catch (e) {
echo "error: $e"
currentBuild.result = 'FAILURE'
}
}
==========================================================================================================================================================================================================================================================
/* The below function delete uploads that exist in the server. */
def delete_upload(server_url,each_upload_id,authentication){
def delete_upload_url = server_url + "/api/v1/uploads/" + each_upload_id
def response = httpRequest consoleLogResponseBody: true,
contentType: 'APPLICATION_JSON',
customHeaders: [[maskValue: false, name: 'id ', value: each_upload_id],
[maskValue: false, name: 'Authorization', value: authentication]],
httpMode: 'DELETE', ignoreSslErrors: true, responseHandle: 'NONE', url: delete_upload_url,
validResponseCodes: '100:599'
if(response.status == 202){
def result = readJSON text: """${response.content}"""
return result['message'].toString()
}
else {
throw new Exception("Incorrect upload id! Please give the correct upload id.")
}
}
错误:
[Pipeline] Start of Pipeline
[Pipeline] node
Running on si0engubudoct09.de.bosch.com in /data/osm-jenkins-slave/workspace/FOSSology/Testing/Test-Jobs/cbl1cob/delete_uploads_Testing
[Pipeline] {
[Pipeline] readFile
[Pipeline] echo
list : [2,
, 3,
, 4,
, 5,
, 6,
]
[Pipeline] echo
error: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.split() is applicable for argument types: () values: []
Possible solutions: split(groovy.lang.Closure), split(groovy.lang.Closure), split(groovy.lang.Closure), wait(), init(), init()
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: FAILURE
========================================================================================================================================================================================================================================================== /根/阿比拉什/上传身份证. txt root@si0engubudoct09:~/阿比拉什#猫上传身份证. txt 2 3 4 5 6
要求:我需要使用文件upload_id. txt中的上载id,并将其作为JSL函数中的循环
有什么建议吗?
1条答案
按热度按时间ryevplcw1#
@Matt Schuchard我无法将变量放入URL
错误:URL未正确获取列表