29217

Jenkins: How to use user defined shell variables when copying artifacts from another project

Question:

In my Jenkins configuration I have a conditional step which exports a custom shell variable called "SUFFIX". I want to use this variable in name the of the project from which I am copying artifacts but it says:

Unable to find project for artifact copy: myProject${SUFFIX}_release

How can I use such a variable or achieve such a behaviour where the project name depends on a job parameter. The job parameter is a boolean value and should stay a boolean value. There should not be a string parameter SUFFIX.

Is this question related: <a href="https://stackoverflow.com/questions/22558326/being-clever-when-copying-artifacts-with-jenkins-and-multi-configurations" rel="nofollow">Being clever when copying artifacts with Jenkins and multi-configurations</a> Do I need the EnvInject plugin to make variables accessible by the Copying artifacts plugin?

Answer1:

Jenkins does not retain environment variable changes between builds or build-steps. This is part of the design, to keep the build environment clean.

You cannot export an environment variable in <strong>Execute Shell</strong> build step, and then use it in <strong>Copy Artifacts</strong> build step. To get around this, you do need <a href="https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin" rel="nofollow"><strong>EnvInject plugin</strong></a>.

<ul><li>Instead of exporting your shell environment variable to the Environment, you need to write it to - properties file, in format param=value </li> <li>Then, using EnvInject build step, load that properties file</li> <li>After that, your newly loaded environment variable will be available to all subsequent build/post-build steps, including Copy Artifacts build step.</li> </ul>

Recommend

  • What is considered a statement in C++?
  • Graph - Modeling dependencies into parallelism/serialism
  • ImageIO throwing NPE in IIORegistry on JBoss AS 7.2.0.Final when updating to JDK 1.7 U45
  • How can I use SQL many-to-many table from Entity Framework?
  • Python file reading and printing, with exceptions and terminations
  • First available date previous day/month/year from a datetime range
  • SQL Reports for Manager/Supervisor/Employee Hierarchy from an Employee Table
  • Definition of slack variable in time window routing
  • Could not find or load main class org.apache.hadoop.fs.FsShell
  • Django ManyToMany relationship with abstract base - not possible, but is there a better way?
  • How to read a text file using Relative path in scala
  • My “Create” View in my “Index” View, is it possible?
  • Mobilefirst Failed synchronizing application from the administration service
  • Gradle test fails with NullPointerException
  • how to UNSELECT row in a ttk.Treeview in tkinter
  • True privateness in Python
  • Hibernate in Glassfish - Ejb3Configuration NoClassDefFoundError
  • Cursor in wrong place in contenteditable
  • How do you keep a running instance for Google App Engine
  • EntLib Way to Bind “Null” Value to Parameter
  • Most efficient way to move table rows from one table to another
  • Spring integration inbound-gateway Fire an event when queue is empty
  • How do I get the list of bad records that didn't load in Bigquery?
  • Cloud Code function running twice
  • Django model inheritance, filtering models
  • std::remove_copy_if_ valgrind bytes in block are possibly lost in loss record
  • Unable to decode certificate at client new X509Certificate2()
  • OOP Javascript - Is “get property” method necessary?
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • Functions in global context
  • Could not find rake using whenever rails
  • Q promise. Difference between .when and .then
  • Illegal mix of collations for operation for date/time comparison
  • Is possible to count alias result on mysql
  • Symfony2: How to get request parameter
  • what is the difference between the asp.net mvc application and asp.net web application
  • ORA-29908: missing primary invocation for ancillary operator
  • XCode can't find symbols for a specific iOS library/framework project
  • Benchmarking RAM performance - UWP and C#
  • How do you join a server to an Active Directory (domain)?