4

I'm working on a multiconfiguration job(Regression_L1) in Jenkins whose task is to run 2 kinds of tests(test1 and test2). In the multiconfiguration job, it triggers an executor job(Regression_executor) to run script for the selected test. The Regression_L1 job is restricted to run in matrix_service_jobs node, while the matrix jobs are to run in the slave node custom_matrix_service_jobs node. The Regression_executor job is restricted to run in remote machines with a specific label(RL1_Test_Machine).

My goal is to test custom build from developers. And so I added a File Parameter(config - File Location: CUSTOMBUILD/mybuild.zip) for the job. The question is how can I access the uploaded file?

Some important info:

  • Regression_executor's workspace: /home/regressionexec/
  • Regression_L1's workspace: /var/work/matrix_service_jobs/Regression_L1
  • Regression_l1 matrix workspaces: /var/work/workspace_user_matrix/workspace/Regression_L1/TEST_PHASE/test1/label/custom_matrix_service_jobs/ and /var/work/workspace_user_matrix/workspace/Regression_L1/TEST_PHASE/test2/label/custom_matrix_service_jobs/
  • $JENKINS_HOME: var/work/jenkins_home

I did not know where to find the uploaded files so I did a search ung linux find. The result is: /var/work/jenkins_home/Regression_L1/TEST_PHASE/test2/label/custom_matrix_service_jobs/builds/${BUILD_NUMBER}/fileParameters/CUSTOMBUILD/mybuild.zip.

How can I copy it to the slave node that executes the test script?

ac22
  • 73
  • 1
  • 2
  • 9

2 Answers2

6

Whatever you enter under "File location", that would be the location and the variable that holds the original filename of the uploaded file.

However, on *nix, neither / nor . are valid variable name characters, so in your case, if "File Location" is CUSTOMBUILD/mybuild.zip system cannot create a variable ${CUSTOMBUILD/mybuild.zip}

The file though is still placed under ${WORKSPACE}/CUSTOMBUILD/mybuild.zip. You can access it with this path too.

You can then use Copy To Slave plugin, to copy the file from master to your slaves

Slav
  • 25,168
  • 9
  • 69
  • 95
  • I think my problem is on the ${WORKSPACE} part. passing `PACKAGE_PATH=echo "${WORKSPACE}/CUSTOMBUILD/mybuild.zip" >> env.txt` as a parameter to the executor however, the equivalent of the of the PACKAGE_PATH points to a path that does not exist. In fact, when I tried to use `find` in the master machine I found the uploaded file to be in JENKINS_HOME, which is different from the workspace of the job. Please see **Some important info** in my original post. Yes, Copy to Slave plugin seems to be what I need. However, it is dependent on obtaining the path of the uploaded file. Thanks. – ac22 May 15 '15 at 06:16
  • 1
    Try changing `CUSTOMBUILD/mybuild.zip` simply to `mybuild`, and then look under the Workspace of the job (through Jenkins UI). The file should be there. Obvsiouly, this is for the job that actually asks for the file parameter. The file you found with `find` is there because that's were Jenkins keeps track of past builds' params (and this is a param). The contents of `$WORKSPACE` is also volatile, and can only be relied on **during** the build. – Slav May 15 '15 at 13:16
  • My bad. I had a mistake on the Build Step. I included a step to clear the workspace `rm -rf *` that is why the file parameter is removed before triggering the executor. Thank you very much! – ac22 May 18 '15 at 05:59
0

I couldn't find my uploaded file under the WORKSPACE, so I ended using something like

"%JENKINS_HOME%\jobs\%JOB_NAME%\builds\%BUILD_ID%\fileParameters\myUploadedFile"
J.J
  • 541
  • 9
  • 23