Limitations of jenkins pipeline to groovy scripts

In the Jenkins pipeline, there are some restrictions when writing groovy scripts.

For example, new File() will not work, it will report "No such file or directory", the reason may be the influence of sandbox mechanism. 

 

Reading files and writing files must be done through pipeline instructions, see: https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/

 

For example, the following code reads a dockerfile, modifies it, and writes it back.

            def dockerFile = readFile "dockerfile"
            println("the original docker file:" + dockerFile)
            dockerFile = dockerFile.replaceFirst("FROM abc.0.1", "FROM abc:0.2")
            writeFile file: "dockerfile", text: dockerFile
            println("changed file:" + readFile(file: "dockerfile"))

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326441879&siteId=291194637