I want to add similar stages to Jenkins pipeline, something like:
pipeline {
stage('Publish archives to Artifactory - common') {
steps {
dir('android/build/artifacts_output/common') {
script {
def server = Artifactory.server 'artifactory'
def uploadSpec = """{
"files": [
{
"pattern": "*.*",
"target": "my-repo/1.0.0/common"
}
]
}"""
server.upload(uploadSpec)
}
}
}
}
stage('Publish archives to Artifactory - core') {
steps {
dir('android/core') {
script {
def server = Artifactory.server 'artifactory'
def uploadSpec = """{
"files": [
{
"pattern": "*.*",
"target": "my-repo/1.0.0/core"
}
]
}"""
server.upload(uploadSpec)
}
}
}
}
}
I need to add some more stages like this, for different modules. Is there a better way to do it, like adding stages with loop, instead of copy-pasting this code many times?
This snippet is written in Groovy. I'm not familiar enough with the syntax of Groovy...
EDIT
Also found this similar question