Jenkins Pipeline Job with file parameter

前端 未结 8 1951
难免孤独
难免孤独 2020-12-01 10:33

I\'m putting together a Jenkins pipeline job which will take a file parameter. I can trigger the job and point it at a file however I can\'t find where the file has ended up

8条回答
  •  借酒劲吻你
    2020-12-01 10:49

    Solved it the following way:

    node {
        deleteDir()
        stage("upload") {
            def inputFile = input message: 'Upload file', parameters: [file(name: 'data.zip')]
            new hudson.FilePath(new File("$workspace/data.zip")).copyFrom(inputFile)
            inputFile.delete()
        }
        stage("checkout") {
            echo fileExists('data.zip').toString()
        }
    }
    

    I know the solution is not that beautiful because the pipeline gets interrupted for the upload but it works.

    Further the "copyFrom" is necessary, because the input stores the "data.zip" in the jobs directory and not in the workspace (don't know why)

提交回复
热议问题