I am testing a seed job in jenkins. So that, I am using dsl groovy script which call uploaded script from a File location parameter" in Jenkins configuration.
So I defined, 'src/test' as a File location parameter".
Then, I am calling it in the dsl step in the seed job using readFileFromWorkspace function.
steps {
dsl{
text(readFile("src/test/UnixDSLJob.groovy"))
ignoreExisting()
removeAction('DELETE')
removeViewAction('DELETE')
}
}
I got this error :
ERROR: (script, line 20) File src/test/UnixDSLJob.groovy does not
exist in workspace
Then, I tried to test if there is no issue about the existance of the file using this command :
def file = readFileFromWorkspace("src/test/UnixDSLJob.groovy")
out.println(file)
I got the same error.
Or, I am sure that I upload the file before lunching the build.
I tried many solutions given here, like using readFile instead ofreadFileFromWorkspace, but I still having same issue.
Related
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
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.
I have a freestyle jenkins job B which will run after the run of job A.
Now I choose:
Promote builds when...
Custom Groovy script
I check Groovy Sandbox and I define a simple groovy script.
When I try to save my job I got this error:
java.net.MalformedURLException: JENKINS-37599: empty classpath entries not allowed
I have to define a class path entry: JAR file path or URL
Definition:
A path or URL to a JAR file. This path should be approved by an
administrator or a user with the RUN_SCRIPT permission, or the script
fails. If the file or files are once approved, they are treated
approved even located in another path.
I really don't know to what file I have to point or what I have to do. Why isn't it just working when I check the sandbox?
This is a jenkins bug. It requires removing that Classpath entry every time before saving the job. I found a workaround, to set the value to any of the existing jars, like https://your-jenkins-host/jnlpJars/slave.jar. This won't affect script execution and won't require you to remember removing that stupid UI block every time you update your jenkins job config.
I had a similar issue and I clicked the red box with the white "X" to close that additional classpath window. I then saved the script.
I am new to Jenkins and I am having trouble to solve the following problem (lack of knowledge). When I make a change in my Git Repo, Jenkins makes a new build with the following ERROR MESSAGE:
ERROR: Unable to find build script at /var/lib/jenkins/jobs/toolxy/workspace/build.xml
Whereby the Name toolxy is the the name of the gitRepo itself. So my question is what I have to do to make the build successful? Where does this build.xml come from? Do I have to create the file manually? What for?
Do I need ant to have a successful build?
I'm beginner for "Jenkins" and following this tutorial.
At the Sixth step I got below error.
xcodebuild: error: Scheme JenkinsTest is not currently configured for the test action.
Build step 'Xcode' marked build as failure
Recording test results
ERROR: Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error?
Finished: FAILURE
In the Test report XMLs I did set "test-reports/.*xml"
I tried to find my solution and also many questions are founded on SO like same issue I have too but did not get solution.
I have some confusion, Is .xml file automatically generated by "Jenkins" or First we manually need to add .xml file ?
In short guide me on right direction based on above error.
You can also enable the 'allowEmptyResults' option so that the junit plugin won't throw an exception when it doesn't find test results.
This way it doesn't matter if the 'test-results' directory exists.
junit allowEmptyResults: true, testResults: '**/test-results/*.xml'
First make sure junit.xml is getting generated after the test run.
Jenkins job at times cannot see past the current workspace. so it is always a good idea to copy the reports back to the current workspace before using it.
cd <path to report>
cp *.xml $WORKSPACE
Now the jenkins should pick-up the report.
Note: The config may show error first(since it cannot find the xml file in workspace) but after a build this should go away and also the result should get recorded
I'm using nosetest (python) to generate an xUnit compatible file and I was getting:
ERROR: No test report files were found. Configuration error?
I was using junit plugin as:
junit "test-results-unit.xml"
junit seems to add WORKSPACE directory by default so using the full PATH to the file wouldn't work either. I created symlink from the resulting file to the WORKSPACE directory to make it work:
sh 'ln -s tests/test-results-unit.xml $WORKSPACE'
junit "test-results-unit.xml"
Other answers suggest copying the files to the workspace directory, but for me simply changing the path to start with '**' seemed to solve the issue
junit '**/test-reports/*.xml'
The Jenkins junit plugin page says that you need to "specify the path to JUnit XML files in the Ant glob syntax". I've not dug into the full details of what this means, but starting the path with '**' was enough to get it working for me.
Thanks #Acid, it really helped me.
First, copy the module/build/test-results to workspace directory
cp -r app/build/test-results $WORKSPACE/test-results
And then I used this wildcard path
**/test-results/**/*.xml
I had the same problem and my test report file name got changed due to an upgrade in scala version,
Hence I have to change from,
junit '/myworkspace/target/myreport.xml'
to
junit '/myworkspace/target/TEST-myreport.xml'
How about:
junit allowEmptyResults: true, testResults: "${WORKSPACE}/test-results/*.xml"
or just:
junit "${WORKSPACE}/test-results/*.xml"
You have to find the path where your test reports are saved in your .jenkins workspace:
/Users/<USERNAME/>/.jenkins/workspace/<PROJECT/>/target/surefire-reports/*.xml
to find the folder type in your terminal:
.jenkins
then
open .