Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Jenkins pipeline step rtNpmPublish raise an error: java.nio.file.InvalidPathException: Illegal char <>> at index 0: #561

Open
tapioreijonen opened this issue Oct 12, 2021 · 6 comments
Labels
bug Create a report to help us improve

Comments

@tapioreijonen
Copy link

Describe the bug
When publishing npm artifact into artifactory using Jenkins pipeline rtNpmPublish step it raise an error:java.lang.RuntimeException: java.nio.file.InvalidPathException: Illegal char <>> at index 0: > @xxxx/license-collector-js@1.1.2 prepack c:\build\workspace\workspace\xxx\xxx\license-collector

This was workin before we update Jenkins Artifactory pluging to version 3.13.1

To Reproduce
Create a Jenkins pipeline job, which build and publish build artifact
`pipeline {
agent {
label 'xxxx'
}

stages {
    stage('Cleanup') {
        steps {
            sh 'printenv'
            echo "${currentBuild.getBuildCauses()}"
            cleanWs()
        }
    }

    stage('Clone') {
        steps {
            "Normal git checkout"
        }
    }

    stage ('Artifactory configuration') {
        steps {
            rtNpmResolver (
                id: "NPM_RESOLVER",
                serverId: "artifactory.xxxx.com",
                repo: "xxxxx"
            )
            rtNpmDeployer (
                id: "NPM_DEPLOYER",
                serverId: "artifactory.xxxx.com",
                repo: "xxxxx"
            )

        }
    }

    stage ('Npm install') {
        steps {
            rtNpmCi (
                args: '--verbose',
                path: ".",
                resolverId: "NPM_RESOLVER"
            )
        }
    }

    stage ('Exec npm publish') {
        steps {
            rtNpmPublish (
                path: ".",
                deployerId: "NPM_DEPLOYER"
            )
        }
    }

    stage ('Publish build info') {
        steps {
            rtPublishBuildInfo (
                serverId: "artifactory.xxxx.com"
            )
        }
    }

}
post {
    unsuccessful {
        emailext recipientProviders: [developers(), culprits(), brokenBuildSuspects()],
            to: "${params.emailNotifyRecipients}",
            subject: '${DEFAULT_SUBJECT}',
            body: '''\

${DEFAULT_CONTENT}


${BUILD_LOG}
'''
}
fixed {
emailext recipientProviders: [developers(), culprits(), brokenBuildSuspects()],
to: "${params.emailNotifyRecipients}",
subject: '${DEFAULT_SUBJECT}',
body: '${DEFAULT_CONTENT}'
}
}
}`

Expected behavior
The build artifact is find out in Artifactory

Screenshots
xxxx-js-1.1.2.tgz
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at sun.nio.fs.AbstractPath.resolve(AbstractPath.java:53)
at org.jfrog.build.extractor.npm.extractor.NpmPublish.pack(NpmPublish.java:135)
at org.jfrog.build.extractor.npm.extractor.NpmPublish.execute(NpmPublish.java:91)
[wrapped] java.lang.RuntimeException: java.nio.file.InvalidPathException: Illegal char <>> at index 0: > @xxx/xxxx-js@1.1.2 prepack c:\build\workspace\workspace\test\xxx\xxxx

Versions

  • Extractor version:
  • Operating system: Latest Windows 64bit,
  • Artifactory Version: Enterprise license 7.24.3 rev 72403900

Additional context
Add any other context about the problem here.

@tapioreijonen tapioreijonen added the bug Create a report to help us improve label Oct 12, 2021
@tlehtimaki
Copy link

As there has been no changes to this and it used to work, it would be nice to know if something has changed with the rtNpmResolver, rtNpmDeployer, rtNpmCi or rtNpmPublish commands that would cause the issue.

@tapioreijonen
Copy link
Author

I also open a ticket https://www.jfrog.com/jira/browse/HAP-1476 where those commands are implemented.

@tapioreijonen
Copy link
Author

Read the code a bit and I have a question.

At bigining of the rtNpmPublish, it run npm pack command, which should return the file name of the created npm package in NpmDriver.java, function pack(). This pack function should return the filename.

When I run the npm pack command using Windows command line it returns al lot of outputs, starting with this ">" character and at the end, it outputs the actual file name. The pack() function only use trim() function to remove trailing/leading white characters.

So the question is, did I miss something how the function pack() parse the created npm package name or is this the root cause of the bug?

@tlehtimaki
Copy link

tlehtimaki commented Oct 15, 2021

We found the problem in rtNpmPublish:

  • in our package.json we have prepack script that runs npm run build
  • this causes log to stdout that rtNpmPublishinterprets as file path
  • this log can be anything produced by the npm prepack that runs before npm pack
  • now rtNpmPublish assumes the file path from the beginning of stdout, this causes the problem
  • it could be solved by reading the last line of stdout that should always be the filename of the .tgz package
  • in our case the prepack runs babel which produces at least one line before the filename

Could you @eyalbe4 please, take a look at this. 👍

@tlehtimaki
Copy link

tlehtimaki commented Oct 15, 2021

Just a note we proved that when no prepack script is defined in package.json (or produce output), the rtNpmPublish will not choke.

@tapioreijonen
Copy link
Author

Conform, that when we run "npm run build", e.g. create a artifact package before "rtNpmPublish" step, the created artifact is published into Artifactory without any problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Create a report to help us improve
Projects
None yet
Development

No branches or pull requests

2 participants