Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use EnvInject Jenkins plugin correctly?

Tags:

jenkins

Work flow I want to create

  1. 'Shell Executors' write variables to build.properties file.
  2. EnvInject plugin reads build.properties injects them as environment variable, so it possible to use them everywhere in the job. job config

I got such exception instead:

[EnvInject] - Loading node environment variables.
Building remotely on master-worker (lucid) in workspace /data/jenkins/workspace/QA-350_MultiJob
[QA-350_MultiJob] $ /bin/sh -xe /tmp/hudson757569632298940894.sh
+ curl --user **** -X POST --header Content-Type: application/json --header Accept: */* -d {
  "description": "string",
  "mode": "DEFAULT",
  "name": "string",
  "start_time": "2015-11-05T13:26:40.626Z",
  "tags": [
    "string"
  ]
} https://****
+ jq .id
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0   144      0    286 --:--:-- --:--:-- --:--:--   286
  0    33    0    33    0   144     49    215 --:--:-- --:--:-- --:--:--     0
+ ID = "563c8d3ae4b0bf061cd3d999"
/tmp/hudson757569632298940894.sh: 1: ID: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
like image 980
Rudziankoŭ Avatar asked Nov 06 '15 11:11

Rudziankoŭ


2 Answers

You do not need to add anything in "Properties Content", as long as the file you are pointing to in "Properties File Path" contains variable assignments (e.g. ID = 123).

  • Verify the file in workspace created by your shell script contains your variable assignment.
  • Clear "Properties Content" box.
  • You may remove $WORKSPACE from the "Properties File Path" - its is relative to your job's workspace by default.

You should than have the variable from the file loaded to the job's environment.

like image 150
Eytan Avisror Avatar answered Oct 07 '22 09:10

Eytan Avisror


Came across this and was having a VERY similar problem..

Same error message informing me that the variable name I was trying create was not found (notice for this question are trying to create a variable named ID and the error is telling us that 'ID is not found')

If you remove the spaces around 'ID = ${curl ' it should resolve the issue.

Variable creation in shell scripts requires no spaces to be used. Example: MY_VARIABLE="my value"

like image 38
Mr. DoMó Avatar answered Oct 07 '22 10:10

Mr. DoMó