jJenkins - Empty workspace after build - maven

I have setup Jenkins with Maven but I am having trouble populating my workspace directory after a build. I get a build success but my workspace directory remains empty? The builds are correctly saving to the builds folder but for some unknown reason, are not copying files to workspace.
I am running on a Mac (created the scm.sh shell to run scm) and fear that this could be the problem? When I try to 'Wipe Out Workspace' in Jenkins I get a:
java.io.IOException: Cannot run program "scm": error=2, No such file or directory
Any ideas would be very appreciated, thanks.

Related

Gradle Could not expand ZIP: is not a ZIP archive

I am trying to unzip an archive file in my Gradle build script.
The archive file exists, and I have checked that it is indeed a zip file by running
file myfile.zip
However, build fails with the following error:
Could not expand ZIP '/.../file.zip': is not a ZIP archive
For Windows:
Please delete the package of the zip file and clean gradle. It will resolve.
One reason this can happen is if the file is damaged or corrupted.
The way to check that is to try manually unzipping the file.
For me, the problem was semi-unrelated. My build directory was owned by root and I was running as a user that did not have permissions to write there. I ended up deleting the dir and the next gradle build handled it.
Yes.. it was due to permission on that file.
For windows:
Give the permission including parent folder as same administrator.
Try it to do it again.
If still not work, delete the zip file and let them create again after 1st step. It will resolve.
I got same error, and after running ./gradlew build --stacktrace found out that resources folder contained Flyway migration file with name "V1.1.98__documents..sql" (double dot). Apparently this caused problems with zipping. Was typo of course.

Maven test-output folder is not updated with the build results(emailable-report is not updated after the build is successful/failure with the result)

Scenario: Send an email after the build with the emailable-report.html.
Am able to achieve the above scenario.
But when the build is completed in jenkins, target folder or test-output folder is not updated after build. which means the jenkins workspace is not updating the target folder or test-output folder after the build. Rather the Jenkins workspace remains with the code checked out from GIT repository.
I want the jenkins workspace to be updated after the build to email the latest emailable-report.html.
Script for the sending the email:
def reportPath = build.getWorkspace().child("test-output/emailable-report.html")
msg.setContent(reportPath.readToString(), "text/html")
Help me with this scenario.
This is just because build is generating in wrong jenkins workspace due the wrong configuration that we have done earlier.
It should be something like
C:\Users\Ashv\.jenkins\workspace\projectname
and for this make sure the below configuration.
Goto Manage Jenkins>>Configure System>>Advanced
Home directory C:\Users\Ashv\.jenkins
Workspace Root Directory : ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}
Build Record Root Directory: ${ITEM_ROOTDIR}/builds
here I am attaching my job screen for all configuration I have done.
you can find the link of image

Change Jenkins job workspace

What I have done :
I have Jenkins set up on my Ubuntu in :
/var/lib/jenkins/
I have a job, that runs every 45 minutes that does a hg pull and hg update --clean default
from my bitbucket repository.So this is running fine.I have a folder
/var/lib/jenkins/jobs/Code Deployement
which contains the latest updated code from my repository.
Problem :
However, I want to access my updated code from
/var/www/html/[project-name]
Query :
Is there anyway i can make jenkins job update this folder instead of the /var/lib/jenkins/Code Deployment folder ? I certainly dont want to make /var/www/html/[project-name] as my jenkins home folder.
How can I achieve what I described above.Will I have to copy the folder from the jobs folder to my desired location after every time the job runs ? Please help me out with the solution,I'am a beginner with automated deployment using Jenkins.
Thank you.
Under "Advanced" you can explicitly choose a working directory for the projects without changing the Jenkins home directory. Check the "Use custom workspace" box and set the directory that Jenkins will pull the code to and build in.
In our setup we wait for the build process to complete in the working directory and add a build step for Jenkins to copy (most) of the files out to the directory that serves up the website. We had issues with file locking preventing the build process if someone (e.g. the testers) were using the site.
One simple way to do it is to create a symlink under /var/www/html/ that points to your code directory, e.g.:
sudo ln -s /var/lib/jenkins/jobs/"Code Deployement" /var/www/html/[project-name]

Trying to compile an XCode project with a workspace on Jenkins slave

I got a Jenkins slave building single xcode projects, working perfectly.
However, I got a project with a workspace where some 3rd party files are setup in the root of the workspace with a gitmodule then imported in to the project as described here.
When Jenkins compiles and reaches AppDelegate.h it throws and error when trying to import a file from the library.
fatal error: 'RestKit/Restkit.h' file not found #import <RestKit/Restkit.h>
I got the project compiling by pointing to the workspace. However it now fails when reaches the packaging stage. I don't see the build directory created in the workspace.
** BUILD SUCCEEDED **
Cannot remove *.ipa files from a non-existing directory:
/Users/leon/Work/projects/wearehive/flatstr/build/Flatstr/dev/jenkins/workspace/Snug-debuOLD/build/Debug-iphoneos
Packaging IPA
FATAL: null
java.lang.NullPointerException
at au.com.rayh.XCodeBuilder.perform(XCodeBuilder.java:421)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:705)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:475)
at hudson.model.Run.run(Run.java:1434)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)
Your Project=>build settings=>Header Search Paths, add follow path:
"$(SOURCE_ROOT)/RestKit/Build/Headers"
Be sure checked box in front of them.
I use xcode plugin and use this for SYMROOT value instead of space fixes the problem.
${workspace}/build/[app name]/Build/Products

ld: library not found for -lLIBRARY_NAME, only when trying to build using jenkins

I have a project that when built from my machine everything runs smoothly. However, when I push my changes and try to generate the build using jenkins, I'm getting the library not found error message.
This is weird because if I login into the jenkins server and I try to do a manual build, everything works as expected, perfect. It's only when I build from withing jenkins that my build is failing.
I'm assuming LIBRARY_NAME as the name of whatever library, in my case is an internal static library.
Any suggestions?
EDIT:
I've setup: Library Search Headers, Other Linker Flags, Target Dependencies, Proper Architectures
I wrestled with this for three weeks until I accidentally stumbled onto this with the help of a coworker. Basically, you must be sure that the path structure created in your repository is replicated in the .jenkins workspace. To do this just be sure that in your project/job configuration in jenkins the Source Code Management > Subversion > Repository URL field must be at the same level as specified in jenkins in your script or Build > Execute Shell > Command field. So here are my settings as an example:
above Jenkins URL = https://myDuncwa.local/duncwa-repo
above Jenkins Build = "cd $WORKSPACE/mobileapps/projects/PictureBoard/trunk/PictureBoard" and line 2 "xcodebuild -project PictureBoard.xcodeproj" no quotes.
above Subversion URL repository = https://myDuncwa.local/duncwa-repo
This will cause the directory structure mobileapps/projects/PictureBoard in my repository to replicated in the .jenkins/jobs/PictureBoard/workspace/mobileapps/projects/PictureBoard directory that is created automatically by jenkins. Note: 1) This will copy the entire repository so be prepared to change this later and 2) .jenkins is a hidden directory created by the install in the installing user's home directory or "~/"

Resources