Unable to delete directory when Invoking Ant only on slave node - jenkins

Build failed on slave server only due to unable to delete only Jar directory.
We are trying to load balance the Jenkins and hence launch the slave node, where we mounted workspace of Master to slave node. We are getting the following error while doing ant clean from the /var/lib/jenkins/workspace/TEST/. However, this is working fine on Master and giving error only on Slave node. Tried upgrading ant version on Slave but no luck. Also check permission and its fine. How can i solve this.
/var/lib/jenkins/workspace/TEST/build.xml:115: Unable to delete directory /var/lib/jenkins/workspace/TEST/jar
Adding to it if there are files inside Jar then only it fails. However, if Jar is empty then it works fine.

Related

how to specify path of directory having package.json for sonar setup in jenkins?

I have a project with below directory structure.
project
-- abc/custom
-- package.json
-- test
-- package.json
-- jenkinsFile
My main project folder lacks package.json. Now I am trying to set up sonar in my jenkins file with below properties:-
'sonar.working.directory':"${WORKSPACE}/abc/custom",
'sonar.sources':"${WORKSPACE}/abc/custom",
'sonar.projectBaseDir': "${WORKSPACE}/abc/custom",
'sonar.javascript.lcov.reportPath': "${WORKSPACE}/test/coverage/lcov.info",
'sonar.projectKey':'#KEY',
'sonar.projectName':'#NAME',
'sonar.projectVersion': '1.0',
'sonar.sourceEncoding':'UTF-8',
'sonar.login': #TOKEN
Whenever I try running the above with jenkins it fails with error:-
home/jenkins/workspace/PROJECT_NAME#tmp/durable/script.sh: line 4: node_modules/sonarqube-scanner/dist/bin/sonar-scanner: No such file or directory
It is not able to locate "sonarqube-scanner" that i have installed in node-modules of abc/custom folder.
The sonarqube-scanner must be installed on the default location on Jenkins agent node where the workspace gets created and not on any other node or directory path.
Looking at the error, I can see 2 probabilities where the things might have gone wrong:
a. The sonarqube-scanner path in Jenkins settings has been wrongly mentioned.
b. sonarqube-scanner itself has not been installed on Jenkins agent node where this code is getting checked out.

ng build not creating assets and such in Jenkins

We're having issues with our automated deployment system.
On our own computers, running ng build generates the dist folder. Within the folder, it has the assets as expected.
I have replicated this, on the build server, manually pulling the git repository, and running the "build file" (the build server runs on Windows Server. The build and deploy process is managed via a PowerShell script for convenience).
When our Jenkins server runs the build script, the assets folder is missing from the /dist/ folder, as well as some other files configured in angular.json.
It is also not properly compiling the stylesheets, which I've believe is due to the same root cause.
The issue persists when running the PowerShell script directly from the Jenkins workspace when the shell is run as a system administrator.
The CLI does not produce any errors.
I'm attaching a verbose log, in case this could be helpful.
https://gist.github.com/cf-jola/6cc6cff138da5105f3b10adffb72895f#file-output-txt
Running the script as the system administrator I've ruled out it being a permissions issue. Jenkins is also managing to create other files, such as the
.js files, and the index.html fine.
My workaround right now is to, via the deploy powershell script, to manually copy the assets folder, how-ever I'd love to get rid of this workaround as we're starting to get multiple files in our angular.json > assets section.
For references:
angular.json https://gist.github.com/cf-jola/6cc6cff138da5105f3b10adffb72895f#file-angular-json
deploy script: https://gist.github.com/cf-jola/6cc6cff138da5105f3b10adffb72895f#file-deploy-ps1
Its a bug, in either Node or Angular CLI.
Because we have brackets, ( & ), in the build path, they get encapsulated in square brackets.
This causes the path: C:\Program Files (x86)\Jenkins\... to become this C:\Program Files [(]x86[)]\Jenkins\... and thereby become invalid.
We discovered the issue by using Process Monitor and looking over the events generated during the build process.

Jenkins archive path with docker environment

We use Jenkins with the 'copyArtifact-Plugin' to archive files from a build job. Now we moved our Jenkins Master into a docker container.
This archive features works very well:
archive artifacts
copy artifacts from other projekts
This archive features doesn't work:
The link 'artifacts of the last succesful builds' from the projekt
website to show and download the archive in browser produces a
jenkins devil with this exception:
java.lang.IllegalArgumentException: The parent does not exist
at hudson.FilePath$IsDescendant.invoke(FilePath.java:3315)
at hudson.FilePath$IsDescendant.invoke(FilePath.java:3295)
Does anybody knows why the link from the project site only works wenn the archive path is directly in the docker container? When the archive path ist outside the docker container and mapped inside the container you can't get the archive. The build results are also outside the container but the master can read this informations.

Create directory using Gradle on Jenkins

I have a Gradle buildscript which works fine locally but on our Jenkins CI environment it seems to work incorrect.
In the gradle file i have a statement that creates a directory:
dockerBuildDir = mkdir("${buildDir}/docker")
This works fine locally but when I execute the build script on a Jenkins machine this directory is not created (I do not get an error message!). I think this is related to the workspace or something but cannot find the cause of the problem.
Any hint what I am doing wrong?

P4 command line client in Jenkins issues on OSX

I've been scratching my head on this issue but haven't found a way around it. I've installed Jenkins on my OSX v10.8.4 using the Jenkins 1.571 installer from the Jenkins website.
It gets installed by default in /Users/Shared/Jenkins/Home folder.
I want to use Jenkins to act as a CI server for my iOS code residing on my company's perforce server. For this I created a user(matching to that of my perforce user along with the same password)on my OSX box. I also copied the P4 command line to /usr/local/bin and correctly setup the P4PORT to point to my perforce server settings. So far so good.
I verified that I was able to connect to my perforce server from command line by using the p4 login command, and it worked successfully.
I then installed the perforce plugin from Jenkins Manage plugins option (https://wiki.jenkins-ci.org/display/JENKINS/Perforce+Plugin).
Now when I create a new job and specify the settings correctly in the perforce plugin piece of the jenkins job, I always get these errors:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/iosbuild/workspace
Using master perforce client: ios-jenkins
[workspace] $ p4 workspace -o ios-jenkins
Caught exception communicating with perforce. Could not run perforce command.com.tek42.perforce.PerforceException: Could not run perforce command.
at hudson.plugins.perforce.HudsonP4DefaultExecutor.exec(HudsonP4DefaultExecutor.java:90)
at com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:331)
at com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:301)
at com.tek42.perforce.parse.Workspaces.getWorkspace(Workspaces.java:61)
at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1615)
at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1576)
at hudson.plugins.perforce.PerforceSCM.checkout(PerforceSCM.java:892)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
at hudson.model.Run.execute(Run.java:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: java.io.IOException: Cannot run program "p4" (in directory "/Users/Shared/Jenkins/Home/jobs/iosbuild/workspace"): error=2, No such file or directory
at java.lang.ProcessBuilder.processException(ProcessBuilder.java:478)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:457)
at hudson.Proc$LocalProc.(Proc.java:244)
at hudson.Proc$LocalProc.(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:780)
at hudson.Launcher$ProcStarter.start(Launcher.java:360)
at hudson.plugins.perforce.HudsonP4DefaultExecutor.exec(HudsonP4DefaultExecutor.java:81)
... 14 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:91)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 19 more
ERROR: Unable to communicate with perforce. Could not run perforce command.
Finished: FAILURE`
First I specified the perforce jenkins plugin to create the workspace for me and also let jenkins to manage my views, but I still got the same above error.
Following is my view map:
//depot/rombay/MarketingApplication/iOS/ianywhere/... //ios-jenkins/depot/rombay/MarketingApplication/iOS/anywhere/...
I then created a workspace using the p4v client, and then deselected letting jenkins create my workspaces and manage my views. The view map remains the same. However, I still get the same error.
My hunch is that since Jenkins is installed in the shared folder it's not able to execute the p4 command. However, I tried doing that and it opened up the clientspec in vi for me, which is I guess the expected behavior, but I still don't understand as to why it says that it can't find the p4 program to work for me.
Any help here would be deeply appreciated as I've run out of ideas as to what could possibly be I doing wrong.
No softlinks are required. Check if you have updated the Global Settings for p4. Manage Jenkins->Global Settings

Resources