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

removePrefix does not support Ant pattern

    XMLWordPrintable

Details

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

    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

          For your information, all publish-over-ssh component type JENKINS issues related to the Publish Over SSH plugin have been transferred to Github: https://github.com/jenkinsci/publish-over-ssh-plugin/issues

          Here is the direct link to this issue in Github: https://github.com/jenkinsci/publish-over-ssh-plugin/issues/101
          And here is the link to a search for related issues: https://github.com/jenkinsci/publish-over-ssh-plugin/issues?q=%22JENKINS-53276%22

          (Note: this is an automated bulk comment)

          gmcdonald Gavin McDonald added a comment - For your information, all publish-over-ssh component type JENKINS issues related to the Publish Over SSH plugin have been transferred to Github: https://github.com/jenkinsci/publish-over-ssh-plugin/issues Here is the direct link to this issue in Github: https://github.com/jenkinsci/publish-over-ssh-plugin/issues/101 And here is the link to a search for related issues: https://github.com/jenkinsci/publish-over-ssh-plugin/issues?q=%22JENKINS-53276%22 (Note: this is an automated bulk comment)
          slide_o_mix Alex Earl added a comment -

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

          slide_o_mix Alex Earl added a comment - Please try recommended approach and reopen if that doesn't meet your needs.
          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?

          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?

          People

            slide_o_mix Alex Earl
            gbosch Gerard Bosch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: