When I am trying to run zowe CLI commnds shell script thru Jenkins, I am getting error as ‘zowe : Command not found’. I am on WIndows platform. Is there any setting or configuration required in Jenkins to run zowe?
Hello Prasad.
Can you give a little more info on how you are trying to run “zowe” command in Jenkins?
Is it from a pipeline or simple job?
For example, when running from a simple job (Freestyle Project), in the Build section, make sure you pick “Execute Windows batch command”. Do not use “Execute shell”, since you are on a Windows host, and shell won’t work as expected.
Before going further, please, provide the way you are trying to run the command, so we can pin point the issue.
Thanks,
Alex
Thank you Alex for your response. Yes, I am running a simple job (Freestyle Project) in following 2 ways. Unfortunately both ways are giving similar error.
-
First I am running simple job (Freestyle Project) with ‘Execute Windows batch Command’ in Build section and mentioning a batch script ‘simple.bat’ in command section of Build. Please note this script has a zowe jobs submit CLI command and echo command. This script runs fine on Windows cmd prompt and submits job on mainframe. But when I run it thru Jenkins I get below error.
“‘zowe’ is not recognized as an internal or external command,
operable program or batch file.
“submitted our job , JOB ID is” jobid
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE” -
Second way is executing simple1.sh shell script in Build Section with ‘Execute Shell’ option. This shell script also has zowe CLI commands. For executing this shell on Windows, I used Cygwin (and gitbash also) command prompt. It is running fine on Cygwin terminal or gitbash terminal. Before executing this shell in Jenkins, I mentioned Shell path in Manage Jenkins–>Configure System–>Shell Executable to sh.exe in bin folder of cygwin. e.g. I mentioned ‘C:\cygwin64\bin\sh.exe’ this path in Manage Jenkins–>Configure System–>Shell Executable. After this when I ran shell in jenkins I received below error.
"+ ./simple1.sh
./simple1.sh: line 2: zowe: command not found
submitted our job , JOB ID is
Job completed in OUTPUT status. Final result of job:
./simple1.sh: line 12: zowe: command not found
./simple1.sh: line 13: zowe: command not found
./simple1.sh: line 14: zowe: command not found
Build step ‘Execute shell’ marked build as failure
Finished: FAILURE"
Hope this information helps you. Any help would be greatly appreciated.
Thank you-
Prasad
If you try adding echo %PATH%
to your Windows batch script or echo $PATH
to your shell script, do you see if the location of zowe CLI (default %APPDATA%/npm/ e.g. C:\Users\xxx\AppData\Roaming\npm ) in the path? It’s possible Jenkins is setting up a different PATH than what you are using in your shell. Not sure if there is a way to configure jenkins so that it just uses the system’s path variable, if that is indeed the problem.
Hi,
Sorry for late reply. As Chris is pointing out, this might be an issue with the PATH variable. But since you are able to run the batch file locally, PATH in Windows should be fine, and it leads me to guess that Jenkins is using a differently defined PATH variable.
I have local Jenkins set up on my Win 10, and I am able to run “zowe” commands directly from ‘Execute Windows batch command’ Build section.
On Slack, someone suggested to add the default C:\Users\xxx\AppData\Roaming\npm
path to the PATH variable in System section. This might work, since System PATH is shared across accounts, but I think we should not pollute that.
One other thing that comes into my mind is the user under which Jenkins is running. Is it set to your windows user? (If i remember correctly, by default it is not)
You can check by doing the following:
- Open Services
- Locate Jenkins, and right-click on it
- Go to Properties -> Log On
- Here you can check under which account Jenkins is running. If it’s not the one you log in to Windows, then you have to change it that one. To do that, just click Browse and use the Check Names field to search for your ID. If you have Active Directory, then you might need to change the Location to “Entire Directory”.
One other advice is to join slack at https://slack.openmainframeproject.org, because the community is bigger, and we could see your questions much faster.
Thanks,
Alex
As a test, I switched the user to Log on as: Local System account
(tested both with the checkbox ticked/unticked for ‘Allow service to interact with desktop’), and got similar error:
C:\Program Files (x86)\Jenkins\workspace\test>zowe -V
'zowe' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files (x86)\Jenkins\workspace\test>exit 9009
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Thank you Chris & Alex for you solution.
I checked %PATH% and I can see zowe CLI npm path in there.
I also tried changing Logon to my id. It got changed but then when I am trying to restart/stop-start the Jenkins service, service is is getting stopped few seconds after starting. So I am checking it.
Meanwhile alternate workaround we found is giving zowe CLI npm path in the command itself in the script. For example,
C:\Users\XXXXXX\AppData\Roaming\npm\zowe zos-jobs submit data-set
Thank you-
Prasad
I am encountering similar issue on issuing ZOWE CLI commands from Jenkins pipeline script.
I installed ZOWE CLI on my Windows laptop, everything works fine and I can issue ZOWE CLI commands to submit jobs on mainframe.
Then I wish to automate tasks via Jenkins, so I installed Jenkins that runs on my Windows laptop as a service and is accessed via https://localhost:8080. First it does not recognize the ZOWE command. Then I give it the full path, and in the next try it doesn’t seem to recognize the ZOWE configuration file, as it asks me for host info:
Reading this thread, I am also wondering if this could be related to the logon method of Jenkins, but I am unable to select the other ‘logon’ option:
Any help will be much appreciated! Thanks.