Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39174

Help text for projectName does not describe all permitted values

    Details

    • Similar Issues:

      Description

      According to jglick in #jenkins, the projectName parameter for Copy Artifact can accept absolute and relative paths to jobs in folders.

      There is no mention of this anywhere in the user-facing documentation.

        Attachments

          Activity

          Hide
          markstosberg Mark Stosberg added a comment -

          I ran into this as well and was also only able to resolve it with help from @jglick in #jenkins.

          In my case, I was trying to copy artifacts from the branch of a multipline build. The Pipeline syntax generated only generated syntax that included the projectName as "My Pipeline". The correct syntax I eventually figured out was "/My Pipeline/mybranch".

          Show
          markstosberg Mark Stosberg added a comment - I ran into this as well and was also only able to resolve it with help from @jglick in #jenkins. In my case, I was trying to copy artifacts from the branch of a multipline build. The Pipeline syntax generated only generated syntax that included the projectName as "My Pipeline". The correct syntax I eventually figured out was "/My Pipeline/mybranch".
          Hide
          jglick Jesse Glick added a comment -

          Well, the syntax offered is going to depend on where you clicked the Pipeline Syntax link; it will offer a path valid from that point. In the case of a multibranch project, you probably want to run it from a sample branch project, so for example from qatest/master you could refer to dev/releases as either /dev/releases or ../../dev/releases. Just like Unix filesystem paths.

          Show
          jglick Jesse Glick added a comment - Well, the syntax offered is going to depend on where you clicked the Pipeline Syntax link; it will offer a path valid from that point . In the case of a multibranch project, you probably want to run it from a sample branch project, so for example from qatest/master you could refer to dev/releases as either /dev/releases or ../../dev/releases . Just like Unix filesystem paths.
          Hide
          jfemia James Femia added a comment - - edited

          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 if it has spaces in the url path.

          def job_name = '/MyBranches/' + java.net.URLEncoder.encode('branches/jamie/spaces in path', 'UTF-8').replace('+', '%20')
          

          I also did not know that the Pipeline Syntax link from different pages affected the behaviour of the snippet generator.

          Show
          jfemia James Femia added a comment - - edited 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 if it has spaces in the url path. def job_name = '/MyBranches/' + java.net.URLEncoder.encode('branches/jamie/spaces in path', 'UTF-8').replace('+', '%20') I also did not know that the Pipeline Syntax link from different pages affected the behaviour of the snippet generator.
          Show
          smokris Steve Mokris added a comment - I drafted a wiki page based on Jesse Glick 's comments: https://wiki.jenkins.io/display/JENKINS/How+to+reference+another+project+by+name …and a PR: https://github.com/jenkinsci/copyartifact-plugin/pull/107

            People

            • Assignee:
              Unassigned
              Reporter:
              jfemia James Femia
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: