How can I use the Jenkins Copy Artifacts Plugin from within the pipelines (jenkinsfile)?

后端 未结 4 2128
醉酒成梦
醉酒成梦 2020-12-01 11:36

I am trying to find an example of using the Jenkins Copy Artifacts Plugin from within Jenkins pipelines (workflows).

Can anyone point to a sample Groovy code that is

4条回答
  •  死守一世寂寞
    2020-12-01 12:27

    name = "/" + "${env.JOB_NAME}"
    def archiveName = 'relNum'
    try {
        step($class: 'hudson.plugins.copyartifact.CopyArtifact', projectName: name, filter: archiveName)
    } catch (none) {
        echo 'No artifact to copy from ' + name + ' with name relNum'
        writeFile file: archiveName, text: '3'
    }
    
    def content = readFile(archiveName).trim()
    echo 'value archived: ' + content
    

    try that using copy artifact plugin

提交回复
热议问题