Jenkins pipeline, retrieve artifact

16 views
Skip to first unread message

dacav

unread,
Feb 28, 2018, 7:52:30 AM2/28/18
to jenkins...@googlegroups.com
Hello everyone

I'm using Jenkins Pipeline to construct some continuous integration thingy.

I'm currently trying to trigger an existing job and take in the generated
artifacts in the current job's workspace.

The following works fine:

pipeline {
agent {
label 'builder-rpm'
}

options {
timestamps()
ansiColor('xterm')
}

stages {
stage('Build Other pipeline') {
steps {
build job: 'Components/components-rpm-build', parameters: [
string(name: 'Component', value: 'libewnotify'),
string(name: 'TargetDistro', value: 'el7'),
string(name: 'RepoServer', value: '')
]
copyArtifacts(
filter: 'results/*.rpm',
fingerprintArtifacts: true,
flatten: true,
projectName: 'Components/components-rpm-build',
selector: lastSuccessful(),
target: "${env.WORKSPACE}/dist"
)
}
}
}
}

The problem of it is that lastSuccessful() will take indeed the last
successful build, meaning that if some other user manages to run a parallel
build faster than me, I'm going to take in their artifacts instead of mine.

According to the "Copy Artifact" page at
https://wiki.jenkins.io/display/JENKINS/Copy+Artifact+Plugin
there should be a way to use a specific job, with `specific`:

def built = build('downstream');
copyArtifacts(projectName: 'downstream',
selector: specific("${downstream.number}"));

There's however no explanation nor examlpe on how to use it in a declarative
pipeline.

Any hint?

Thanks in advance for any help.

Reply all
Reply to author
Forward
0 new messages