MS Build Failure on Jenkins - jenkins

I am new to Jenkins CI. However the issue looks very easy enough but its not working for me. My source code is in GIT and i am using Git repository for that.
I am getting the error below.
Thanks in Advance.
Started by user abc
Building on master in workspace /var/lib/jenkins/workspace/Hello World
git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url
Fetching upstream changes from
git --version # timeout=10
using .gitcredentials to set credentials
git config --local credential.helper store --file=/tmp/git7943155421179786207.credentials # timeout=10
git fetch --tags --progress +refs/heads/:refs/remotes/origin/
git config --local --remove-section credential # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 833228fa50173e7977b4d5ee86c1385b5c6494be (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 833228fa50173e7977b4d5ee86c1385b5c6494be
git rev-list 833228fa50173e7977b4d5ee86c1385b5c6494be # timeout=10
Path To MSBuild.exe: msbuild.exe
Executing the command msbuild.exe NimbusAutomation.sln from /var/lib/jenkins/workspace/Hello World
[Hello World] $ msbuild.exe ABCAutomation.sln
Build step 'Build a Visual Studio project or solution using MSBuild' changed build result to FAILURE
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Warning: this build has no associated authentication, so build permissions may be lacking, and downstream projects which cannot even be seen by an anonymous user will be silently skipped
Finished: FAILURE

This can be caused by not configuring a jobs authorization policy correctly.
Check either the downstream job to see its configuration, or go to
Manage Jenkins-> Configure Global Security -> Access Control for Builds -> Configure Build Authorizations in Project Configuration
And check the global settings.
After finding the parent settings, go to the project giving the error select the same configuration in the section that looks like :
If this still does not work, you might also need to make sure that the user has the adequate permissions if you are using matrix based security.
Manage Jenkins-> Configure Global Security -> Authorization
And in the authorization matrix make sure the necessary user has build permissions
See also
Authorize project plugin
How To Configure Access Control For Builds

Thanks. I did all the advised settings above, it only resulted in Warning message to disappear, the build still fails.
The build works fine on my local Command prompt when i pass - msbuild.exe NimbusAutomation.sln but still fails on jenkins...
Path To MSBuild.exe: msbuild.exe
Executing the command msbuild.exe msbuild.exe NimbusAutomation.sln NimbusAutomation.sln from /var/lib/jenkins/workspace/Hello World
[Hello World] $ msbuild.exe msbuild.exe NimbusAutomation.sln NimbusAutomation.sln
Build step 'Build a Visual Studio project or solution using MSBuild' changed build result to FAILURE
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE

Related

Jenkins build job giving error - java.net.BindException: Address already in use: JVM_Bind

I am trying to build simple Jenkins build job in my local workspace. I have built simple mvc gradle application. Jenkins build job has been setup with required gradel task but getting below error for jmx
Running as SYSTEM
Building in workspace C:\Users\harshal\.jenkins\workspace\MVCApp
The recommended git tool is: NONE
No credentials specified
> git.exe rev-parse --resolve-git-dir C:\Users\harshal\.jenkins\workspace\MVCApp\.git # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://github.com/harshalpatil2012/HelloWorld-MVC-App.git # timeout=10
Fetching upstream changes from https://github.com/harshalpatil2012/HelloWorld-MVC-App.git
> git.exe --version # timeout=10
> git --version # 'git version 2.9.0.windows.1'
> git.exe fetch --tags --progress -- https://github.com/harshalpatil2012/HelloWorld-MVC-App.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
Checking out Revision a7cf612bd16cc92d5e56137284de5318ce9beec2 (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f a7cf612bd16cc92d5e56137284de5318ce9beec2 # timeout=10
Commit message: "spring gradle demo app"
> git.exe rev-list --no-walk a7cf612bd16cc92d5e56137284de5318ce9beec2 # timeout=10
[MVCApp] $ C:\Windows\system32\cmd.exe -xe C:\Softwares\apache-tomcat-8.5.75\temp\jenkins5788250459304119055.sh
Microsoft Windows [Version 10.0.18363.1556]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\harshal\.jenkins\workspace\MVCApp>[Gradle] - Launching build.
[MVCApp] $ cmd.exe /C "C:\Users\harshal\.jenkins\workspace\MVCApp\gradlew.bat clean build && exit %%ERRORLEVEL%%"
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 1099; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
I have disabled jmx as below but still not sure why I am gettign same error in build execution.
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
I have deployed JENKINS war in my local tomcat 8.5 using intellj
The error is telling you that there is some service or process using port 1099. You need to find what process is using that port, then kill/end it (or change the port gradle is using) and rerun your job. I'm not a Windows user but the same principle should follow: Using NetStat.exe you can see the used ports in your machine with their processes. Also this answer can also help you.
This issue was due to the Intellj trying to connect to JMX during startup. I switched to eclipse and Jenins setup was working correctly via my eclipse tomcat server deployment.

Jenkins - using GIT_ASKPASS to set credentials

I've set up some credentials in Jenkins for bitbucket and double-checked the Credentials settings (e.g. logging in manually) however when I try it in Jenkins it just spins forever giving this output:
> git config remote.origin.url <bitbucket url> # timeout=10
Fetching upstream changes from <bitbucket url>
> git --version # timeout=10
using GIT_ASKPASS to set credentials <bitbucket account email> Bitbucket
> git fetch --tags --progress <bitbucket url> +refs/heads/*:refs/remotes/origin/*
> git fetch --tags --progress <bitbucket url> +refs/heads/*:refs/remotes/origin/*
Note that the URL is fine when public. But when set to Private it simply fails with no output.
Is there anyway to debug this in a bit more detail?
I had a similar issue, with Jenkins on a Windows server. I installed git with credentials manager and whenever it tried to checkout a private repository, it would wait for me to input credentials manually in the server. Disabling the git credential manager fixed it for me.
I already had an option to input credentials in the git plugin so didn't need a separate credentials manager.
This is on MacOSX.
I changed the Jenkins setting on Git path to /usr/local/git as well as unset the credential.helper using git config, both don't work.
Finally, the problem was resolved by creating a default keychain file for jenkins in ~jenkins/Library/Keychains folder. Herewith is the steps...
sudo su jenkins
mkdir ~jenkins/Library/Keychains
cd ~jenkins/Library/Keychains
security create-keychain -p [pwd] ./Login.keychain
security login-keychain -d user -s ./Login.keychain
check default keychain setup properly
security default-keychain
git fetch --tags --progress https://github.com/....git +refs/heads/:refs/remotes/origin/
After that, the github userid/password is stored in jenkins default keychain and it will be used on jenkins build.
I had this problem on OSX. My issue was that Jenkins was using the wrong Git executable (I verified this by disabling the checkout step and adding which git before anything else).
I ran which git in terminal and copy-pasted the path into Manage Jenkins -> Global Tool Configuration -> Git -> Path to Git executable. It worked after that.
I had a similar issue, with Jenkins on a Windows server. I installed git with credentials manager and whenever it tried to checkout a private repository, it would wait for me to input credentials manually in the server. Disabling the git credential manager fixed it for me.
Actually, that should now (Q1 2021) work without having to disable the credential helper with Git 2.30.
"git credential(man)' didn't honor the core.askPass configuration variable (among other things), which has been corrected with Git 2.30 (Q1 2021).
See commit 567ad2c (15 Oct 2020) by Thomas Koutcher (koutcher).
(Merged by Junio C Hamano -- gitster -- in commit e0f6ad2, 02 Nov 2020)
credential: load default config
Signed-off-by: Thomas Koutcher
[jk: added test]
Signed-off-by: Jeff King peff#peff.net
Signed-off-by: Junio C Hamano gitster#pobox.com
Make git credential fill(man) honour the core.askPass variable.
As noted by kymikoloco in the comments, upgrading to the latest (Nov. 2021) Git for Windows 2.34 seems enough to solve the issue.
I had such problem with Jenkins on Windows 10. It always showed failure with permission denied error, code 128 returned by git.exe after ...GIT_ASKPASS for credentials step. Changing credential.helper and env.variable GIT_ASKPASS did not help me at all, the same behaviour.
Then i checked up which git.exe in cmd where git and was suprised, it was SmartGit's internal one.
I changed it to JGit in Jenkins global settings and it works now.
https://i.stack.imgur.com/IBfIi.png
Its works for me!
Goto Dashboard --> configuration
Scroll down to find Git plugin
input Global Config user.name Value: ex: jenkins
input Global Config user.email Value ex: youremail#gmail.com
you need to generate an SSH key from Git and add it to Bitbucket

Where to put ${library.pipeline-utils.version} when using Git SCM to setup Global Pipeline Library

I am trying to setup a global pipeline library that will be explicitly loaded using #Library() per these instruction. I have this working fine with respect to loading the default library version from master branch.
What I am unable to do is figure out how to configure things so that it can load different branches upon request using the Library('lib-name#branch-name') syntax.
The instructions say:
"When using Legacy SCM, you will need to include ${library.pipeline-utils.version} in the SCM configuration somewhere."
I have tried using ${library.pipeline-utils.version} as the value for the Branch Specifier which is the only logical place I can think to put it. But that just break things. Attempts to load the library fail with:
Fetching upstream changes from ssh://git#stash:7999/jen/pipeline-utils.git
> git --version # timeout=10
> git fetch --tags --progress ssh://git#stash:7999/jen/pipeline-utils.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/${library.pipeline-utils.version}^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/${library.pipeline-utils.version}^{commit} # timeout=10
> git rev-parse origin/${library.pipeline-utils.version}^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
This makes me think I put the variable in the right place but Jenkins is not interpolating it. (Bug?)
This is using Jenkins 2.7.1 and Pipeline version 2.4
This is how I set it, using version variable ${library.CpsGlobal.version} and Branches to build / Branch Specifier :
ps. Please remove "-" character from library name as it's not supported by Groovy.
Work for me:
Library name: testlib
Default version: branchname
Branches to build: ${library.testlib.version}
There is finally now a 'modern scm' implementation for Git that works as we are using that.

Jenkins - Build loop

Solutions
When configing the branchs to build remove the wildcard *:
*/master to be only master
This error only occours when a GIT SCM is related to the JOB.
Ex: I have a daily job to build an Android project.
First i thought that it was a cron problem, currently im using 50 10 * * *, but i have tried H 10 * * * without any success. When the time comes, it always build the job (Failure or Success) and it queue another job.. and so on...
Would last have run at Friday, May 22, 2015 10:01:58 AM BRT; would next run at Saturday, May 23, 2015 10:01:58 AM BRT.
Even a build with parameter it queue a another job everytime.
So it stays in a build loop, forever..
Config:
Jenkins ver. 1.614.
Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-46-generic x86_64)
GIT client plugin: 1.17.1
GIT plugin: 2.3.5
Console Output:
Started by an SCM change
Building in workspace .../jobs/PROJECT_NAME/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url ssh://GIT_ADDRESS/ # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
Fetching upstream changes from ssh://GIT_ADDRESS/
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress ssh://GIT_ADDRESS/ +refs/heads/master:refs/remotes/origin/master
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Multiple candidate revisions
Scheduling another build to catch up with PROJECT_NAME
Checking out Revision e6d726c2d31cb0d7e6fad4362ee85e6fac1712c6 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f e6d726c2d31cb0d7e6fad4362ee85e6fac1712c6
> git rev-list e6d726c2d31cb0d7e6fad4362ee85e6fac1712c6 # timeout=10
[Gradle] - Launching build.
[android] $ gradle clean build assemble
...
Maybe the problem is this?
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Multiple candidate revisions
Scheduling another build to catch up with PROJECT_NAME
The build loop:
Job Config:
Global Config:
Review the beginning of the console logs, for both the job that you manually started, and the job that gets queued next automatically.
In the beginning of the console log, it gives a reason for why the build was triggered, for example 09:46:05 Started by an SCM change or 16:06:58 Started by user Slav. Please add to the question the start of both console logs.
Edit:
Now that we know that Jenkins detects an SCM change trigger we can further speculate that what's causing this behaviour is an SCM post-commit hook of some sort, or another script activation sending a request to Jenkins.
Post-commit hooks should not work if SCM polling is not enabled, but nothing else makes sense, so let's investigate that avenue. Add /pollingLog/ to the build URL of the build number that was triggered "by SCM change". There is a chance that nothing would be found, but if there is, but let's make sure.
Next, if possible, bind Jenkins to a different IP address and/or port. If there are "rogue" scripts that are triggering secondary builds, they won't be able to adapt to changed address.
Edit 2:
Looks like there is a bug in git client plugin itself, it was fixed in version 1.6.2. Please check the version of your git plugins.
Sources: https://issues.jenkins-ci.org/browse/JENKINS-10767 and https://issues.jenkins-ci.org/browse/JENKINS-20286
Above screen shot looks fine but i am sure there must be some other configuration.
can you provide detail (rest of the) configuration too?
Please give below code in Build periodically section and try if that resolves the issue
H(0-50) 10 * * *
Make sure your repo doesn't have more than one branch that matches your Branch Specifier by using the full path to the branch: "refs/heads/master" instead of "*/master"

Using custom workspace in Jenkins causes git timeout

I'm trying to checkout, and build my git project in a custom folder using Jenkins. I have set the custom workspace from the "Advance Project Options" tab. However, whenever I try to run the project, I get the following error:
Building in workspace /myapp
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/.../... # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
ERROR: Error fetching remote repo 'origin'
ERROR: Error fetching remote repo 'origin'
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE
But if I run the project in the default workspace, it seems to work fine.
I'm wondering whether the structure of my custom workspace is wrong. Basically, I have the following setup:
The name of my git repo is "myapp". When I use the defualt workspace, the project is checked out, and built in: /var/lib/jenkins/jobs/myjob/workspace/[files inside myapp repo]. After this, I have to copy the files from the default workspace to my actual folder using:
cp /var/lib/jenkins/jobs/myjob/workspace/* /myapp/.
But for the custom workspace, I have given the directory as /myapp. I want Jenkins to checkout the code from git into /myapp, and then do the build. Would the folder structure cause any problems? If not, why is it failing?

Resources