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

removePrefix does not support Ant pattern

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Incomplete
    • Labels:
    • Environment:
      Jenkins for windows (Jenkins ver. 2.138)
      publish-over-ssh plugin version 1.19.1
    • Similar Issues:

      Description

      As per documentation, both `sourceFiles`and `excludes` support Ant patterns to remote publish artifacts such as:

       

      `sourceFiles: '*/target/*jar'`

       

      But the `removePrefix` is not compatible with such patterns. So it seems not to be possible to strip a prefix (e.g. `**/target/`) in that situation.

       

      I would like to publish a set of JARs to a remote server without the full path (or prefix).

      How to handle this situation? I have the following:

      ```

      sshPublisher(
          //alwaysPublishFromMaster: true,
          publishers: [
              sshPublisherDesc(
                 verbose: true,
                  configName: 'foo',
                  transfers: [
                      sshTransfer(
                          sourceFiles: '*/target/*jar',
                          removePrefix: '**/target/',
                          remoteDirectory: '/tmp/testpublish'
                     )
                  ],
                  sshCredentials: [
                      //TODO - replace with placeholder ${user}
                     username : 'myuser',
                      // key: '''----BEGIN RSA PRIVATE KEY----
      // (Insert private key here or use keyPath instead)
      // ----END RSA PRIVATE KEY----'''
                      keyPath: 'c:/users/userFoo/.ssh/id_rsa'
                  ]
              )
           ]
      )

      ```

      And I get the following error:

      SSH: Connecting from host [XXXXXX]
      SSH: Connecting with configuration [foo] ...
      SSH: Creating session: username [fooUser], hostname [XXXXXXXXXXX], port [22]
      SSH: Connecting session ...
      SSH: Connected
      SSH: Opening SFTP channel ...
      SSH: SFTP channel open
      SSH: Connecting SFTP channel ...
      SSH: Connected
      SSH: cd [/tmp]
      SSH: OK
      SSH: Disconnecting configuration [foo] ...
      ERROR: Exception when publishing, exception message [Failed to remove prefix from file named [foovar/target/fooArtifact.jar]. Prefix [**/target/] must be present in all file paths]

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          I think you want flatten: true in the sshTransfer block. Can you try that and see if it does what you want?

          Show
          slide_o_mix Alex Earl added a comment - I think you want flatten: true in the sshTransfer block. Can you try that and see if it does what you want?
          Hide
          slide_o_mix Alex Earl added a comment -

          Please try recommended approach and reopen if that doesn't meet your needs.

          Show
          slide_o_mix Alex Earl added a comment - Please try recommended approach and reopen if that doesn't meet your needs.

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              gbosch Gerard Bosch
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: