2
votes

I am still having problems with jenkins when coping artifacts from a project that is selected by using a variable value. I read the question: copy artifacts build step using a dynamic project name alternatives and I tried it, but, still it doesn't work. Maybe you could help me find the problem.

Enviroment:
Jenkins ver. 1.460
Copy Artifact Plugin ver. 1.24

User:
luis.ribeiro - all rights in: Overall;Slave;Job;Run;View;SCM;Artifactory

Jenkins Jobs:
build_project_2_0
build_project_1_0
deploy_project

1° Test:
Description: Run deploy_project and copy artifacts from build_project_2_0 and build_project_1_0

Configuration of deploy_project in Copy artifacts from another project:
Project name: build_project_2_0
Which build: Lastest successful build
Stable build only: checked
Artifacts to copy: **/*.war
Target directory: libs/wars
Optional: unchecked
Flatten directories: unchecked

Result:
Copied 5 artifacts from "build_project_2_0" build number 244
The same result when testing with Project name: build_project_1_0



2° Test:
Description: Run deploy_project and copy artifacts from build_project_2_0 and build_project_1_0. But the Project name comes from a parameter.

Configuration of deploy_project:
in This build is parameterized
Parameter type: Choice
Name: project_name_parameter
Choices:
build_project_2_0
build_project_1_0

in Copy artifacts from another project:
Project name: $project_name_parameter
Which build: Lastest successful build
Stable build only: checked
Artifacts to copy: **/*.war
Target directory: libs/wars
Optional: unchecked
Flatten directories: unchecked

Result:
in Copy artifacts from another project under Project name appears this message: Value references a build parameter, so it cannot be validated.

When running:
Unable to find project for artifact copy: build_project_2_0
This may be due to incorrect project name or permission settings; see help for project name in job configuration.
Build step 'Copy artifacts from another project' marked build as failure
The same when build_project_1_0


3° Test:
Description: Run deploy_project and copy artifacts from build_project_2_0 and build_project_1_0. But the Project name comes from a parameter.

Configuration of deploy_project:
in This build is parameterized
Parameter type: Extended Choice Parameter
Name: project_name_parameter
Parameter Type: Single Select
Value: build_project_2_0
Property Key: build_project_2_0
Default Value: build_project_2_0
Default Property Key: build_project_2_0
Quote Value: checked

in Copy artifacts from another project:
Project name: $project_name_parameter
Which build: Lastest successful build
Stable build only: checked
Artifacts to copy: **/*.war
Target directory: libs/wars
Optional: unchecked
Flatten directories: unchecked

Result:
in Copy artifacts from another project under Project name appears this message: Value references a build parameter, so it cannot be validated.

When running:
Unable to find project for artifact copy: build_project_2_0 This may be due to incorrect project name or permission settings; see help for project name in job configuration. Build step 'Copy artifacts from another project' marked build as failure The same with build_project_1_0


4° Test:
Description: Run deploy_project and copy artifacts from build_project_2_0 and build_project_1_0. But the Project name comes from a parameter.

Configuration of deploy_project:
in This build is parameterized
Parameter type: Extended Choice Parameter
Name: project_name_parameter
Parameter Type: Single Select
Value: build_project_2_0
Property Key: build_project_2_0
Default Value: build_project_2_0
Default Property Key: build_project_2_0
Quote Value: unchecked

in Copy artifacts from another project:
Project name: $project_name_parameter
Which build: Lastest successful build
Stable build only: checked
Artifacts to copy: **/*.war
Target directory: libs/wars
Optional: unchecked
Flatten directories: unchecked

Result:
in Copy artifacts from another project under Project name appears this message: Value references a build parameter, so it cannot be validated.

When running:
Unable to find project for artifact copy: build_project_2_0 This may be due to incorrect project name or permission settings; see help for project name in job configuration. Build step 'Copy artifacts from another project' marked build as failure The same with build_project_1_0


I still didn't get it running, could someone help me with this problem? Thank you in advance, Luis

3

3 Answers

2
votes

It looks correct. I am using copy artifacts with a parameter myself. I can only suggest a few things:

  • Check that project name (the one you are copying from) has no spaces or other special characters. I've had a number of problems with that.
  • Check for capitalization in the project name
  • Try echoing your variable before the copy artifacts step, maybe you will notice a discrepancy
2
votes

Had the same problem. As the error already states, in my case it was just the missing permission.

Go into your "source"-Job/Project where you want to copy artifacts FROM, and check that

Permission to Copy Artifact

is correctly set to the job you want to copy INTO. (Or set to a wildcard like *).

1
votes

I had the same problem and replaced copyArtefactPlugin with this shell script, note that my param is the named "jobname" using the ParameterizedBuildPlugin:

jobsdir=/var/lib/jenkins/jobs

function copy_artefact() {
  if [ -e "$jobsdir/$jobname/lastSuccessful/archive/" ]; then
  mkdir -p $target

  (
    cd $jobsdir/$jobname/lastSuccessful/archive/
    rsync -a $artefacts_pattern $target/ > /dev/null 2>&1 || true
  )
  fi
}

artefacts_pattern="*/noarch/*.rpm"
target="$WORKSPACE/RPMS/noarch"
copy_artefact

artefacts_pattern="*/x86_64/*.rpm"
target="$WORKSPACE/RPMS/x86_64"
copy_artefact