0

N.B.: I dunno if my question is in an understandable format or not, but I tried my best to put it in the right way

job1 has 2 versions of OS configured in jenkins (Linux and Windows)

job1 triggers database_script.py

database_script.py -----this has 2 files(file1.tar.gz and file2.tar.gz)

How can I tell jenkins to load

  • file1.tar.gz if the os=linux

  • file2.tar.gz if the os=windows

in the predefined parameters?

Prometheos II
  • 334
  • 3
  • 14
avi
  • 37
  • 2
  • 8
  • Is `database_script.py` downloading the file to jenkins? Alos what kind of Jenkins job you have? – Yug Singh May 01 '19 at 14:17
  • No it is not downloading the file to jenkins. the database_script.py loads the file – avi May 01 '19 at 14:26
  • I have given something like this when there is only 1 os. TEST_ENV_BRANCH=${TEST_ENV_BRANCH} OPTION=load_a_new_database DATABASE=file1.tar.gz now i have 2 os. how to give condition in this case – avi May 01 '19 at 14:33
  • IMO you can use `Conditional BuildStep Plugin` to set the value of `file` variable depending on the OS. – Yug Singh May 01 '19 at 14:49
  • Posted the same in the answer as people facing issue sometimes ignore the comments. Pls accept the same if it was helpful by clicking on the tick mark to the left of the answer.It may help others also if they face the similar kind of issue. – Yug Singh May 02 '19 at 13:25

2 Answers2

0

This thread has several answers that could help you identify the OS, assuming you only use one non-Unix OS (Windows).

Here's the selected answer:

As far as I know Jenkins only differentiates between windows and unix, i.e. if on windows, use bat, on unix/mac/linux, use sh. So you could use isUnix(), more info here, to determine if you're on unix or windows, and in the case of unix use sh [...]

There is also an example there, if you are interested.

Prometheos II
  • 334
  • 3
  • 14
0

It is not possible for do conditional checks inside the predefined parameters.

IMO you should use the Conditional BuildStep Plugin to set the value of file variable depending on the OS and that value will be used inside predefined parameters.

Yug Singh
  • 3,112
  • 5
  • 27
  • 52