UTF-8 char in path used by groovy in Jenkins - jenkins

I need to copy a file, using a groovy script in Jenkins (pipeline). This file has the character ü in it, which results in the file not being found. I've tried renaming the file to a standard u, and it works. However, this is not an option, I need the ü. Any suggestions how to solve this?
Edit: I'm using Windows 7, using the batch command xcopy.
Edit2: The command being issued is:
bat "xcopy \"${files[i].path}\" \"${path}\""
Where files[i].path is the file name containing the ü character, and path is the complete path where to put the file.

Related

In a Jenkins Pipeline script, how do I assign a path with a space to an environment variable?

I'm assigning a path with a space in it to an environment variable using the following syntax:
environment {
ZIP_HOME = "C:\\Program Files\\7-Zip"
}
I'm trying to use 7-Zip to zip my files and using the variable as the path to the 7-Zip executable.
bat "%ZIP_HOME%\\7z a programdata-${BUILD_NUMBER}.zip ${WORKSPACE}/Staging/programdata"
I also tried putting braces around ZIP_HOME.
bat "${ZIP_HOME}\\7z.exe a programdata-${BUILD_NUMBER}.zip ${WORKSPACE}/Staging/programdata"
I get the following message in the console output:
'C:\Program' is not recognized as an internal or external command
I also tried putting single quotes around 'Program Files' within the path above but get the same message.
The syntax I used for the bat "{ZIP_HOME}\7z is an answer I found on this site but it didn't work for me.
Thank you in advance.

How to run QAC tool from command line?

I have a C project and I would like to run QAC tool v7.0 from command line. I tried the following option,
C:\qac.exe -via <project_name.prj>
However, when I run the above command. I get an error saying the "VersionTag" is not found. The "VersionTag" string is the first line in the .prj file. I am not sure this is the right way to run this tool. Any help appreciated.
The qac -help is not giving valuable information either. The tool version is pretty old and the company 'Programming Research' behind this tool also has been renamed? to Perforce. They do not have any information about command line invocation either from the existing documentation or webpage.
The QAC utility is the "engine" part of the QAC package, corresponding to a compiler.
It won't be happy being run on command line without a number of environment variables:
QACBIN must point to the bin directory of the QAC package installation;
QACHELPFILES must point to the location of message help files;
QACOUTPUT points to the location where output files will be generated (binary .err file for each source file and textual .met file containing semantic and metric information.
The -via parameter to the command line should point at a text file containing other parameters used by the utility.
The .prj file is a package-level file defining the location of C source files being analysed plus their configuration settings files, among other things. It definitely should not be passed directly as a parameter to the QAC utility.
This should get you started, and other questions need to be more specific.

Notepad++ sets incorrect path when running script

I have a simple script that I want to import into another with require, but when I run it from Notepad++ I get the usual error that require produces.
The funny thing is that it worked an hour ago and I did not restart the computer since then.
The files are in the same directory, so the simple file name (without .lua) worked and should still work. (relative path)
Lua runs the script just fine.
this is what I entered in Notepad:
cmd /k lua "$(FULL_CURRENT_PATH)"
Earlier I also had a problem with Penlight, maybe there is some connection, so here it is:
I tried to require"pl" but it failed to find the module. (ran from SciTE, worked prevously)
I tried it in the Lua command line and it worked like a charm.
Tried again in SciTE and voila it worked again.
I have no idea what causes any of them.
ps.: using the lfs module and os.execute("cd /d ...path...") did not work
Lua is searching for your required module in the folders of LUA_PATH. In the script you run via F5, put this statement:
print('current path is:')
os.execute('cd')
require 'someModuleThatDoesntExist'
After printing the "working" forlder (Program Files/Notepad++), it tries to find the required module and fails. The traceback shows that Lua looks through many different folders, none of them being the one containing FULL_CURRENT_PATH, so it can't find the module.
You have several choices:
put your scripts in one of the listed paths
set LUA_PATH in your environment to contain the folder name where your scripts are located
change package.path from your script so it knows where to look for other modules. You could do this by either:
including an extra parameter to your F5, namely CURRENT_DIRECTORY, and make your script take its first command line param (CURRENT_DIRECTORY) to add it to package.path
parse arg[0] when your script starts, to get the folder containing script, and extend package.path
For example with #3, first option, you would use
cmd /k lua "$(FULL_CURRENT_PATH)" "$(CURRENT_DIRECTORY)"
in notepad++ and in your Lua module you would use
thisModuleDir = arg[1]
package.path = thisModuleDir .. ";" .. package.path
require 'yourmodule'

Paths in Lua: Unable to run script in Windows for Lua that requires 'wx'

I am using Lua for Windows.
I am trying a sample script from the wxLua website; however, when I run the script, it fails on the first line, which is require 'wx' with:
lua: cannot open wx: No such file or directory
However, when executing require 'wx' in the REPL/interpreter, it works OK.
I have done another script to output print(package.cpath) and print(package.path), and they seem the same to me as in the REPL.
Why, when running the script, is it not able to find 'wx'?
In this instance, I am running both the script and the shell/REPL from the same folder.
The value of package.cpath (produced by test script and Lua shell):
.\?.dll;.\?51.dll;C:\Program Files (x86)\Lua\5.1\?.dll;C:\Program Files (x86)\Lu a\5.1\?51.dll;C:\Program Files (x86)\Lua\5.1\clibs\?.dll;C:\Program Files (x86)\ Lua\5.1\clibs\?51.dll;C:\Program Files (x86)\Lua\5.1\loadall.dll;C:\Program File s (x86)\Lua\5.1\clibs\loadall.dll
and package.path (again, the same from the script and Lua shell):
;.\?.lua;C:\Program Files (x86)\Lua\5.1\lua\?.lua;C:\Program Files (x86)\Lua\5.1\lua\?\init.lua;C:\Program Files (x86)\Lua\5.1\?.lua;C:\Program Files (x86)\Lua\5.1\?\init.lua;C:\Program Files (x86)\Lua\5.1\lua\?.luac
There is a wx.dll in C:\Program Files (x86)\Lua\5.1\clibs which is referenced by the cpath value above.
OK, this was my own stupidity: I named the file wx.lua, so obviously require was trying to pick up the script itself.
By simply renaming the file, it works fine.

Setting Java path on Windows for Ant

Just downloaded the latest version of Ant and installed at:
C:\apache-ant-1.8.4
I added the following to the Env Path variable:
...;C:\apache-ant-1.8.4\bin
When I open a terminal window and type:
ant -version
I get:
Files\Java\jdk1.7.0_07"" was unexpected at this time.
In System variables I have the variable JAVA_HOME set to:
"C:\Program Files\Java\jdk1.7.0_07"
so it appears that "ant -version" is struggling to read the space in JAVA_HOME even though it is in quotes.
I see an alternative post on this topic:
Ant and Eclipse
but it doesn't tackle this specific point.
Has anyone else encountered this problem and know the answer?
My guess is current definition of JAVA_HOME has unwanted double quotes. Show output of set JAVA_HOME on command window. It should not have any double quotes.
Please start command prompt. Set the JAVA_HOME again
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07
Hmmm, it should be fine with quotes. Could be something else in your path. If all else fails you could revert to dos 8.3 notation.
dir /x
Which gives
13/01/2013 03:57 PM <DIR> PROGRA~1 Program Files
13/01/2013 03:57 PM <DIR> PROGRA~2 Program Files (x86)
In case anyone else is still encountering this problem, I am on Windows 7 and was experiencing the same. I was using the GUI provided by right-clicking the "computer" icon to attempt to set the JAVA_HOME path to the relevant program files folder (C:\Program Files (x86)\Java\jdk1.7.0_45). This will not work! The GUI doesn't accept spaces in paths. Command line however, does. Use set JAVA_HOME= C:\Program Files... to get it working, filling out the rest of the path with the location of your jdk installation.

Resources