Jenkins Copy Artifact unable to find folder/multiProjectPipeline/branchWithSlash -
i have jenkins lts 2.60.2 on windows server 2016 , using these plugins:
- folders plugin (6.1.0)
- copy artifact plugin (1.38.1)
- pipeline plugin (2.5) + dependent pipeline sub-plugins
- various other dependent plugins...
see pipeline use artifacts 2 projects associated same git branch name more details setup, sum have these items:
- playground (a folder created folders plugin group these following items)
- frontend (multibranch pipeline)
- backend (multibranch pipeline)
- configure (pipeline parameter called branch_name)
the frontend , backend git repos, both have branch called master , 1 called release/2017.2.
the idea call configure pipeline automatically after each successful build, passing git branch name. automatically triggering configure pipeline works.
what doesn't work , need fix, step inside configure pipeline copy artifacts multibranchpipeline/specificbranch.
if branch_name parameter (or upstream pipeline) master works. if branch_name is: release/2017.2 error:
error: unable find project artifact copy: playground/frontend/release%2f2017.2 may due incorrect project name or permission settings; see project name in job configuration. finished: failure
the configure pipeline looks this:
node { stage('prepare') { def projectname = "playground/frontend/" + "${branch_name}".replace("/", "%2f") step([$class: 'copyartifact', projectname: "${projectname}", selector: [$class: 'statusbuildselector', stable: false]]) } stage('archive') { archiveartifacts '**' } } as can see replace / %2f (it's needed).
if don't use "playground" folder (all pipelines is, not inside folder item), works. if use folder , use master branch, works. doesn't work if use folder , branch name 2017.2. doing wrong? can making work? of if it's bug (i searched in https://issues.jenkins-ci.org , found bugs similar setup folder doesn't work, have been fixed... wonder...) in copy artifact plugin, please file bug , share link here, can monitor progress...
thank you.
i found issue. configure pipeline failing find branch slash because encoding incorrect.
so, in question, in configure pipeline:
this (replace / %2f) wrong , generates error:
def projectname = "playground/frontend/" + "${branch_name}".replace("/", "%2f") this proper way encode slash, , works:
def projectname = "playground/frontend/" + urlencoder.encode("${branch_name}", "utf-8").replace("+", "%20") credits to: http://www.pipegrep.se/copy-artifacts-from-jenkins-pipeline-jobs.html
update: actually, investigated bit further , added echo "${projectname}" before step, previous , fixed projectname, , noticed difference %2f lowercase.
uppercase, this: %2f works:
def projectname = "playground/frontend/" + "${branch_name}".replace("/", "%2f") so, fixed configure pipeline looks (i kept replace function, enough case):
node { stage('prepare') { def projectname = "playground/frontend/" + "${branch_name}".replace("/", "%2f") step([$class: 'copyartifact', projectname: "${projectname}", selector: [$class: 'statusbuildselector', stable: false]]) } stage('archive') { archiveartifacts '**' } }
Comments
Post a Comment