Access file parameter in jenkins

ac22 picture ac22 · May 14, 2015 · Viewed 16.3k times · Source

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?

Answer

Slav picture Slav · May 14, 2015

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