Adding groovy file from workspace for seed job - jenkins

I have a seed job in Jenkins to create a job to build the workspace. I want to add the job groovy file from the repository. How do I specify the file path for the grooovy on the seed job build step?
I am trying to add it from the file system on the configuration. I get the error file not found. I have tried adding the complete path and also the name of the file.

I have found the solution for it.
You can specify just the relative path to the workspace to access the groovy files.

Related

adding file to jenkins pipeline build folder after cloning repository but before tests stage

I have a file in some folder on my computer that i want to add to the jenkins pipeline build folder before testing stage, without addind this file to the repository. is there a way to do that? this file is a config.yaml that contains a relevant version.
thanks

How can I explore Jenkins workspace?

I want to scan file stored in my Jenkins project workspace.
for example, when I make a project named my_project, I will get report pattern from Jenkins like **/report.xml. and to find report.xml file, I will explore in my own plugin.
since when I print pwd on jenkins console, it prints where my plugin written, not jenkins workspace. so I need to know how to explore jenkins workspace in my plugin.
thanks!
If you're asking where your jenkins workspace is, it is in the workspace folder where you can find all your projects. It should be relative to your plugin folder: ../workspace. You can try to change directory using the relative path. Hope this helps.

jenkins parameter From Properties file

I have 3 Jenkins jobs to be run in serial.
Run a Ant File
Run another ANT File
Run a command line
All the above jobs use a file path which is set in a properties file.
Ex Job 1 , Executes ANT file placed in file path location
Job 2 , Executes another file placed in same file path location
Job 3 , Executes command line to do SVN update in same file path location
I need to parameterize the file path in all three builds from properties file.
Can anyone help me with possible approach?
Thanks In Advance
This answer could be a little high level. You can use Jenkins Pipeline as a code for this approach instead of using 3 freestyle jobs.
You can create 3 stages which performs these 3 steps. Pipeline as a code supports reading of properties from different file types (json, yaml etc.)
Look for the "EnvInject" plugin. This lets you inject properties into your build as environment variables; these assignments survive build step boundaries.
If the property file is checked in, you can load it in the Build Environment section before the build steps start executing. If the property file is generated during the build sequence, you can add a build step between where the property file is created and where it is used.
Once set, if the property file contains "FOO=/path/to/folder" then in configuring Jenkins things you would refer to $FOO or ${FOO} (for example, an Ant build step might specify "${FOO}/build.xml"; in Windows batch script execution FOO shows up as an environment variable and is referenced by %FOO% (i.e., "#echo Some_Useful_Piece_Of_Data > %FOO%\data.txt"
More information can be found here: https://wiki.jenkins.io/display/JENKINS/EnvInject+Plugin

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.

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

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.

Resources