Giter VIP home page Giter VIP logo

Comments (3)

bubi1311 avatar bubi1311 commented on August 22, 2024 2

Thank you @sephiroth-j !

The file encoding of the bom.json was UTF-8. But the jenkins was the problem.

In our environment we have a jenkins master running on Linux and a jenkins slave running on windows 2019.
I added two user environment variables:

  • JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
  • LANG = en_US.UTF-8

Source of this information was: https://www.linkedin.com/pulse/how-resolve-utf-8-encoding-issue-jenkins-ajuram-salim#:~:text=In%20normal%20cases%20Jenkins%20pass%20the%20characters%20in,4%20bytes%29%20which%20can%20encode%20all%20possible%20characters.

After that, the bom.json for angular is uploaded successfully. So the ticket can be closed / rejected.

I just wonder why I could upload a bom.json for nuget-packages in the same jenkinsfile and environment and with the bom.json for npm/angular it did not work.

Maybe that's a point for the documentation?

Thank you and sorry for opening the issue!

Stefan

from dependency-track-plugin.

sephiroth-j avatar sephiroth-j commented on August 22, 2024

Please check the encoding of the file and the encoding of the Jenkins machine where this actions runs on. The source of the MalformedInputException is likely to be located in Jenkins core functionality.

    /**
     * Reads this file into a string, by using the current system encoding on the remote machine.
     */
    public String readToString() throws IOException, InterruptedException {
        return act(new ReadToString());
    }


    private static class ReadToString extends MasterToSlaveFileCallable<String> {
        private static final long serialVersionUID = 1L;


        @Override
        public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
            return Files.readString(fileToPath(f), Charset.defaultCharset());
        }
    }

https://github.com/jenkinsci/jenkins/blob/5cecd13ec34c7a710b782db1a5d9f751d3e1c07c/core/src/main/java/hudson/FilePath.java#L2365-L2379

Versions of Jenkins prior to 2.346 did not used the default charset (1, 2), they used Files.readAllBytes(Path). Now, Files.readString(Path, Charset) is used and the only difference that matters is this call .

        return JLA.newStringNoRepl(ba, cs);

https://github.com/openjdk/jdk11u-dev/blob/edf4fb0a00b49141bd6c02d184901f93c2d09100/src/java.base/share/classes/java/nio/file/Files.java#L3287

from dependency-track-plugin.

sephiroth-j avatar sephiroth-j commented on August 22, 2024

The next major release will update the Jenkins baseline and incorporate the file reading changes introduced in Jenkins 2.346.

from dependency-track-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.