I have close to 60 artifacts(jar) created from a project I want to upload it to nexus ,I have tried diff wildcards it failed.
can I create a loop or is there a beter way to do this .
below is snippet from my jenkins file
nexusArtifactUploader artifacts: [
[artifactId: "test-services", classifier: '', file: "/server/services/deploy/*.jar', type: 'jar']
],
credentialsId: NEXUS_CREDENTIAL_ID,
groupId: "$group",
nexusUrl: NEXUS_URL,
nexusVersion: 'nexus3',
protocol: 'https',
repository: NEXUS_REPO ,
version: "$nexus_version${BUILD_NUMBER}-SNAPSHOT"
}
}
I added a for loop and let uploader iterate over the artifacts. Im not sure if its the right approach .but it does the job as of now . still looking for better options
let me know if i can improve the below.
def FILES_LIST = sh (script: """ls 'server/services/deploy/' """,returnStdout: true).trim()
//DEBUG
echo "FILES_LIST : ${FILES_LIST}"
//PARSING
for(String ele : FILES_LIST.split("\\r?\\n")){
nexusArtifactUploader artifacts: [
[artifactId: "$ele", classifier: '', file: "server/services/deploy/$ele", type: 'jar']
],
credentialsId: NEXUS_CREDENTIAL_ID,
groupId: "com.devops",
nexusUrl: NEXUS_URL,
nexusVersion: 'nexus3',
protocol: 'https',
repository: NEXUS_REPO ,
version: "1.0.0-${BUILD_NUMBER}-SNAPSHOT"