Jenkins CopyArtifact 步骤 - 无法找到工件复制的项目

标签 jenkins jenkins-pipeline

基于这篇试图在我的环境中测试管道代码的帖子。但它给出了以下错误消息。如何修复他的管道代码?

ERROR: Unable to find project for artifact copy: test
This may be due to incorrect project name or permission settings; see help for project name in job configuration.
Finished: FAILURE

How can I use the Jenkins Copy Artifacts Plugin from within the pipelines (jenkinsfile)?
pipeline {
    agent any
    stages {
        stage ('push artifact') {
            steps {
                sh '[ -d archive ] || mkdir archive'
                sh 'echo test > archive/test.txt'
                sh 'rm -f test.zip'
                zip zipFile: 'test.zip', archive: false, dir: 'archive'
                archiveArtifacts artifacts: 'test.zip', fingerprint: true
            }
        }

        stage('pull artifact') {
            steps {
                sh 'pwd'
                sh 'ls -l'
                sh 'env'
                step([  $class: 'CopyArtifact',
                        filter: 'test.zip',
                        projectName: '${JOB_NAME}',
                        fingerprintArtifacts: true,
                        selector: [$class: 'SpecificBuildSelector', buildNumber: '${BUILD_NUMBER}']
                ])
                unzip zipFile: 'test.zip', dir: './archive_new'
                sh 'cat archive_new/test.txt'
            }
        }
    }
}

最佳答案

如果启用授权(如 rbac),则必须向项目授予“复制工件”权限。在项目配置中,General -> Permission to Copy Artifact,勾选并设置可以复制Artifact的项目

关于Jenkins CopyArtifact 步骤 - 无法找到工件复制的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48834762/

相关文章:

Jenkins 管道: Check status of another project last build

jenkins - 运行时为从代理上运行的每个 jenkins 作业创建 pv/pvc

jenkins - 即使jar在Maven本地,Gradle也会尝试访问远程存储库

javascript - 加载表单时,如何在 Jenkins jelly 脚本中获取对 Builder 配置的表单元素的引用?

docker - Jenkinsfile-Build Agents问题

jenkins - Kubernetes大师作为Jenkins奴隶

jenkins-pipeline - 如何在 Jenkinsfile 中的 Jenkins 管道代码中添加 gerrit-trigger 事件

Jenkins 共享库,CpsCallableInvocation

java - Jenkins:Cucumber Test Runners 执行顺序

linux - Jenkins 在远程 docker 代理中运行 sh 卡住