File not found exception while reading .js file within jenkins workspace - jenkins

I am facing a weird issue here. In my jenkins job I've configured it to pull my project's source code from artifacts. So I get 2 directories in workspace called classes and resources. Now some of my tests are failing with FileNotFoundException, stating ABCD.js not found in the given path. When I check this path in the jenkins workspace, this file exists there.
I am not sure about the problem. However, there are following tasks which I've added in the build steps.
1. Download the jar from the artifacts.
2. Unjar the downloaded jar in workspace.
3. Run the tests in the workspace.

Related

Error in configuring JUnit in Jenkins: 'Tests/tests.xml' doesn’t match anything: even 'Tests' doesn't exist

I have created a freestyle project in Jenkins and I want to publish a JUnit result report after the build. The problem is that I don't know how to fill the field Test report XMLs because everytime I type the path of an xml file a red line appears saying
'Tests/tests.xml' doesn’t match anything: even 'Tests' doesn't exist
In reality the Tests folder exists and is inside Jenkins workspace folder and also the tests.xml file exists.
I have moved the Tests folder with its content to the MyProjectName folder that has automatically been created by Jenkins in the workspace. Because apparently the path is not relative to the workspace, but to the project folder that is contained in the workspace.

Unable to deploy war file on to Tomcat8 in jenkins

I'm doing a project as part of DevOps certification.
I need to build a pipeline which contains around 6 steps.
In the 5th step, I need to generate a .war file (which is successful).
In the last step, i need to deploy the war file which contains artifacts on to tomcat using Jenkins.
The project keeps failing. Is that something because of incorrect configuration. Here are the attached screenshots of build, post-build actions, and the console output of project.
Build and post-build actions
console-output of the project
Where am I doing it wrong.
There's issue either while reading your dependencies from pom.xml file or there are some missing dependencies. The stack trace gives build failure in gameoflife-web module.
Try building the same module in Eclipse IDE and you'll find the same error there and you can solve this by adding proper dependencies.
This issue is not of Jenkins when the build is not successful, it will always fail.

Run Ant tast from Jenkins on Perforce

I'm trying to integrate Jenkins with Perforce, but I'm having a few problems.
I managed (apparently, because Jenkins still shows a "Unable to check workspace against depot" message) to link Jenkins to Perforce.
My project includes an Ant script to make the build and I cannot figure out how to use it.
I've added an Ant build step, indicating the name of the ant file (dev_build.xml), but when I run the job Jenkins complains that it cannot find the Ant file.
Jenkins looks for the file in its workspace, but the file is actually located in Perforce's workspace. I expected Jenkins to check out the project but this is not happening: the folder Jenkins\Workspace\MyProject is empty.
I've then copied the Ant file into Jenkins workspace folder, but obviously the Ant fails because it cannot find the source folder.
Any ideas?
I had to create a new perforce workspace dedicated to Jenkins, mapped to the workspace folder.
P4 now synchronizes the files correctly.

Archiving artifacts not in the workspace when build fails

When an ANT build step fails in my build I'd like to archive the logs in order to determine the problem. The relevant logs, however, are not located in the workspace, so I have to use a full path to them.
The standard artifact archiving feature does not work well with full paths, so first I have to copy the logs into the workspace within some build step so that I can later archive them. I do not want to incorporate the copying code into the original ANT script (it does not really belong there). On the other hand, since the build step fails the build I can't execute the code that copies the artifacts into the workspace as a separate build step as it is never reached.
I am considering using ANT -keep-going option, but how will I then fail the build?
Any other ideas (artifact plugins that handle full paths gracefully, for example)?
Update: I've worked around the problem by creating a symbolic link in the workspace to the directory that contains the files to be archived. Kludgy, but effective.
I would recommend using Flexible Publish plugin in conjunction with the Conditional Build Step plugin.
The Flexible Publish plugin allows you to schedule build steps AFTER the build steps have normally run. This allows you to catch both successful and failed builds and execute something - say a script that copies the files from OUTSIDE the workspace to INSIDE the workspace. The Conditional BuildSet plugin allows conditionalizing the steps so that they only run when the build fails. Using these two plugins, you can copy the files into the workspace upon failure, then archive them with the usual Jenkins mechanisms.

TeamCity: How To enable FTP in ANT?

I have to copy files after build on a TeamCity-Agent via FTP. The orndinary buildjob works itself works fine. The triggering of a custom script finish successfull, too.
The step "copy files via ftp" fails with the following error:
[15:34:31]: copyFiles
[15:34:31]: [copyFiles] ftp
[15:34:31]: [ftp] Could not create type ftp due to java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClientConfig
I searched the web for a while and found many times the same answer: "You have to put commons-net.jar and jakarta-oro.jar in your ANT-plugin directory." So I downloaded these two files and copied it into C:\TeamCity\buildAgent\lib, but the error still exists.
Now the question:
Where do I have to copy these files to make FTP work? Or am I on the wrong track?
You've put the jar into the wrong place, it must be in the classpath of Ant, not in the classpath of the build agent.
You should find ant.zip file (TeamCity\WEB-INF\plugins\ant-tool\agent\ant.zip) and put the required jar (commons-net-1.4.1.jar, for example) inside ant\lib directory of the ant.zip file.
After the zip is re-packaged, TeamCity will update build agents with the new Ant version and commons-net dependency will be automatically available for Ant via its own classpath.
Note that you will have to repeat this step every time you update TeamCity to a new version.
Another option is to install Ant on build agent machines manually and configure TeamCity to use custom Ant installation (with all the required custom dependencies in the Ant's lib directory), however it's inconvenient if you have many build agents, but you will not have to repeat this step when updating TeamCity server.
Ant-net-task tool is bundled with TeamCity. This tool has jar files necessary for FTP, sshexec, scp and mail.
To use it Additional Ant command line parameters: -lib "%teamcity.tool.ant-net-tasks%" should be added.

Resources