Jenkins / Upload file to Jenkins machine - jenkins

I try to upload file to my jenkins machine.
I try to use the File Parameter option, and put in the File location line:/opt/myFolder.
I wish that if I'll choose a.txt file from my local machine, then it will be uploaded to /opt/myFolder/a.txt.
But it gives me an error: FATAL: /opt/myFolder (Is a directory)
How can I fix it?

See my answer here, How to upload a .xlsx file to jenkins job. Basically the name you enter in the File Parameter setting will be the name of the file, so in your case you have set File location to be /opt/myFolder, however it should be the actual file location, so /opt/myFolder/a.txt. This do however mean that the file will have the same name each time.
And as Christopher Orr points out in the comments, the file location should be a relative URL so that it is loaded into the workspace, that way it won't hinder you from running jobs in parallel and on different machines.

Related

Jenkins Error "Microsoft Excel cannot access the file"

I am using jenkins to run a .bat file that is in location
C:\Users\foo\Desktop\xxx.bat
which internally
copies from another machine an excel
calls a vbs script found in D:
D:\foo\Newtask.vbs
that opens a file:
C:\Users\foo\Desktop\xxx\xxx\xxx\New.xlsm
The error I am getting is
For the first excel: The system cannot find the path specified
For the second New.xlsm:
D:\foo\Newtask.vbs(14, 1) Microsoft Excel: Microsoft Excel cannot access the file 'C:\Users\foo\Desktop\xxx\xxx\xxx\New.xlsm'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook
I find it odd that jenkins can access and run .bat in foo user's directory while it cannot find C:\Users\foo\Desktop\xxx\xxx\xxx\New.xlsm --> I checked it exists.
When running the .bat manually i have no problem.
Any ideas?
I had the same issue. Solution from this page worked https://techcommunity.microsoft.com/t5/sql-server-support-blog/error-8216-microsoft-office-excel-cannot-access-the-file-8217/ba-p/317477
...x64: Create the following directory:
C:\Windows\SysWOW64\config\systemprofile\Desktop
x86: Create the following directory:
C:\Windows\System32\config\systemprofile\Desktop...

Jenkins can't find file on the slave/agent?

I have changed our Jenkins setup from everything running on one machine to a master-agent/slave setup. Before that everything worked fine, now I am facing issues that some programs I am calling that access files can't find them.
Case 1:
(Pls don't ask why it is so complicated, but the file structure is given and I can't change it)
I am calling a python script, that iself calls a batch file
filepath= os.path.abspath(os.path.join(pamFolder, "run.bat"))
p = subprocess.Popen(filepath, cwd=pamFolder, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
... and the batch file again a jar file with the actual program
java -XX:-UseGCOverheadLimit -cp "../..;../../libs/*" -jar ..\..\myjarfile.jar
Within the jar file there is an access to a file on the disk failing with an error message that the file can't be found:
ERR : The file was not found in the specified path 'U:\somefile.txt'. Please check this path for access and your configuration!
Case 2:
I am calling a batch file from Jenkins that is calling some other exe and in the end trying to open a file in Excel via the COM interface. Here I am getting the following exception (Excel can't access the file):
Unhandled Exception: System.Runtime.InteropServices.COMException: Microsoft Excel kann auf die Datei 'D:\Jenkins\workspace\myJob\someDir\someFile.xlsm' nicht zugreifen.
Question
As previously mentioned, both jobs were working in the previous setup. Both files DO exist.
I suspect that Jenkins / the programs are trying to find the files on the master where they are not available.
Is there any way to tell Jenkins that the called tools are fully executed on the slave node or in some other way tell them where to find these files?
EDIT
The job is already running on the slave. The console shows Running on [slave name] in D:/Jenkins/workspace/xxxxx.
The master is configured in a way that only jobs assigned to it run on the master. So pretty much all jobs should run on the slave.
EDIT2 / SOLUTION
It turned out that the 2 issues are caused by different things.
Case1: Solved this by using the UNC path
Case2: Solved by a mixture of giving the necessary permissions as described here and starting the slave service with a user with admin rights.
From my experience with this issue, usually it has to do with your SCM setup.
But as you stated that the files DO exist I think there might be the possibility that U:\ is a network share? Then consider changing your path to use a UNC path.
If that's not the case check if your jenkins slave as sufficient user rights to access said file.
You can tell Jenkins to run the job on the designated slave as follows:
Under Nodes > [SLAVE] > Configure, specify a label for the slave.
Under [Job] > Configure > Restrict where this project can be run, enter the label.
Now when you build, the console output of the job should read correctly along the lines Running on [SLAVE] (build_agent_01) in C:/jenkins and the files must be accessible.

Using Atom with Hydrogen. The working directory for Atom is one folder up from the current file's location. How do i change it to the current folder?

In both Hydrogen and using a plug-in terminal platform, the default directory is one folder up from where my code file resides.
E.g., I’ll be working on a file with path, say, parent/code/file.py. When I run pwd in the plug-in's terminal or the equivalent via Hydrogen in the python script I get parent/, but I need it to be parent/code/ to import files etc.
Perhaps the default directory for Atom is the project that is folder of the project that is open?
Any ideas how to change the default current directory for Atom (or is it package specific) to the file i’m working on/executing in Hydrogen?
In the hydrogen settings you can choose the location where the kernel should be started.
The default is the 'First started project's directory'. You can choose 'Current directory of the file' there, which should give you what you want.

ADD command with network path in Windows Containers Dockerfiles

I'm creating some Windows Container images that I need but the source file I want to ADD are in a network share \\myserver\myshare\here.
I've tried in any possible way but I always get the message error The system cannot find the path specified.
Is it because I have not yet found the right way to set it or is it that it is just not possible?
From the Docker site:
Multiple resource may be specified but if they are files or directories then they must be relative to the source directory that is being built (the context of the build).
Is that why I can't accomplish what I need?
Full error message: GetFileAttributesEx \\myserver\myshare\here\: The system cannot find the path specified.
Whatever you ADD or COPY must be in the docker build context.
When you do this:
docker build .
That directory param (the . in the example) is the context that is copied and sent to the Docker daemon. Then the docker daemon use those files to COPY or ADD. It won't use any file that is not in that context.
That is the issue that you are experiencing. I'm not sure how you can solve it anything than copying the files from \\myserver to your build directory.
ADD is capable of download files by providing an URL (should investigate if it supports Windows' shares)

TDS and TFS integration

am getting below issue while connecting the TDS with VS 2015.
Creating directory
"\10.207.7.199\c$\inetpub\wwwroot\DEVCMS\Website_DEV". C:\Program
Files
(x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets(560,5):
Error MSB3021: Unable to copy file "C:\Program Files
(x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\TdsService.asmx"
to
"\10.207.7.199\c$\inetpub\wwwroot\DEVCMS\Website_DEV\TdsService.asmx".
Access to the path
'\10.207.7.199\c$\inetpub\wwwroot\DEVCMS\Website_DEV' is denied.
Also am able to access the \\10.207.7.199\c$\inetpub\wwwroot\DEVCMS\Website\_DEV path from build server.
This looks like you are attempting to deploy with TDS to a target website and you do not have permission to do so. Try running Visual Studio in 'administrator mode' to see if this resolves the permission issue.
Also, validate that the path you are attempting to deploy to is correct. It does not look valid, as I would have expected it to have a double slash at the beginning for a network path and then a slash at the end before _DEV.
Also, you appear to be accessing the C$ drive on a networked server. Typically you must be the administrator on that system in order for this to function correctly. I would recommend instead setting up a UNC Share folder that you will allow to write to a particular folder (maybe the Website folder) for any requests from your deployment system.

Resources