| It is also important to note that if the Multibranch Pipeline is searching in branch folders with forward slashes in the sub-job names (or any other url-encodable char), it generates sub-jobs with encoded names. Copying the artifacts from these projects require you to specify the folder path, followed by the url-encoded name of the job. This is logical in terms of being able to resolve Folders containing jobs in Jenkins, but may trip you up when writing groovy. e.g. if I have a Multibranch project called "MyBranches", with base of https://my.repo, and I tell it to search for branches in /branches/jamie/* and it finds /branches/jamie/a and /branches/jamie/b, copying artifacts from these jobs requires me to use /MyBranches/branches%2Fjamie%2Fa. As a side node on that, unless I am using java.net.URLEncoder wrong, I have to replace the output of encode + with %20 in order for the string to match the job name.
def job_name = '/MyBranches/' + java.net.URLEncoder.encode('branches/jamie/a', 'UTF-8').replace('+', '%20')
I also did not know that the Pipeline Syntax link from different pages affected the behaviour of the snippet generator. |