Have teamcity checkout on build agent machine - macos

We have a team city server installed on a server named pluto. It's a Windows Server machine. There is a build agent on Pluto used to do VS related builds.
We have another build agent connected to this TeamCity server instance called YOSX, a build agent that is running on Mac mini Yosemite.
I've created a build to build a solution on YOSX with rake script. As a VCS Root Checkout option I've selected Automatically on Agent.
Ok, I am expecting that perforce p4 app will be called by TC agent on YOSX machine, but when I run a build, I get an error:
Collecting changes in 1 VCS root (2s)
[Collecting changes in 1 VCS root] VCS Root details
[VCS Root details] "eyeleo.mac.dev" {instance id=98, parent internal id=31, parent id=Desktop_EyeLeoMac_EyeleoMacDev, description: "perforce: p4.radacode.net:1666: perforce stream: '//EyeLeo.Mac/dev'"}
Failed to collect changes, error: Unable to find P4 command-line client at path '//Applications/p4' on pluto for user PLUTO$
Why is trying to checkout on pluto with user $PLUTO while I specifically set it to checkout on build agent's machine.
P.S. Yes, I've set the build requirements so that the build configuration in question is only compatible with YOSX build agent.

The server does not try to checkout the sources, but it still collects the information about changelists: modified files, commit messages etc.
This information will be used to display diffs, relevant issues, to track possible causes of test failures.
Please, install p4 on the PLUTO as well.

In my case p4 file on YOSX (build agent machine) was in PATH, but didn't have execute permissions. chmod +x p4 solved the puzzle.

Related

Jenkins with Windows ssh - PATH not working [duplicate]

Tried with the configure option, not able to find the tools
configuration option and the git executable section. Seems like it
occurs after a successful build only. Please help.
Here's the output I receive after building the project on the console output section:
Building in workspace C:\Users\Anishas\.jenkins\workspace\Sample123
Cloning the remote Git repository
Cloning repository https://github.com/AnishaSalunkhe/HelloWorld.git
> C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123 # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init C:\Users\Anishas\.jenkins\workspace\Sample123
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:656)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:463)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1057)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Error performing command: C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1726)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1695)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1691)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1321)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:654)
... 12 more
Caused by: java.io.IOException: Cannot run program "C:\Users\Anishas\git" (in directory "C:\Users\Anishas\.jenkins\workspace\Sample123"): CreateProcess error=5, Access is denied
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:240)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1715)
... 16 more
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 22 more
ERROR: null
Finished: FAILURE
This wasted so much time on my Jenkins Windows slave.
I knew git was in the path because I executed "where git" in the build job's batch command.
where git
C:\Program Files (x86)\Git\cmd\git.exe
Apparently the Jenkins Git Plugin executes ** before ** the environment is inherited.
SET YOUR SLAVE's PATH to Git ( Just DO IT !! )
1) Go to your Windows slave configuration
Manage Jenkins > Manage Nodes
2) Select your slave configuration
3) Check Tool Locations under Node Properties
4) Enter complete path to git executable including git.exe
[x] Tool Locations
Name: (GIT) git
Home: C:\Program Files (x86)\Git\cmd\git.exe
See screenshot:
Go to Manage Jenkins / Global Tool Configuration and set Path to Git executable:
set the path to git.exe and not only to the directory of the git file in both the locations of tool configurations.
Check for below command in Jenkins Server in linux Env:
`whereis git`
you will get the path like /usr/bin/git
Place it in Manage jenkin>Global Tool Configuration> under git path mention /usr/bin/git
Rerun job again
Sometimes this error occurs when disk space is less. so do check the space of your machine where jenkins is hosted. :)
If anyone is using Jenkins with freshly installed Xcode, you'll need to agree to the license using sudo xcodebuild -license or agree through UI.
There can be multiple reasons for that
Check the Permission of the Folder or the Worker Node, In my case 3rd one was the issue because of not providing permissions to the users and groups. As a result you may need to do
sudo chown -R user:group folderName
Check you have configured the SSH Key, if you are using Private Repo from GitHub.
Path Must be provided inside Jenkins Global Configuration of Default Git
In my case,
I have installed git on my slave server. Download-git
Run cmd command
where git
and update your git path with exe file like below in Jenkins node configuration.
C:\Program Files\Git\cmd\git.exe
Go to your Windows slave configuration, Manage Jenkins > Manage Nodes > Select your slave > configure
Check "Tool Locations" under "Node Properties" and give the full path what you got from 'where git' command and save.
yes I have faced the same issue on the Linux ec2 instance but I fixed it through
First of all on your server run the below command, and this command will return to you
$ which git
this command will return to you the actual path of the git, where your git is installed like that /usr/bin/git copy this path.
open your Jenkins > go to manage Jenkins >Global tool configuration > paste the in this field "Path to Git executable
Windows:
1. Install git in windows machine
2. The git.exe path is C:\Program Files\Git\cmd\git.exe (by default, unless you change during installation)
3.Now need to show the path of git.exe in Jenkins git plugin tool
a)manage Jenkins>Global Tool Configuration>Git
b)Add git : name: anything and Path:C:\Program Files\Git\cmd\git.exe
4. Then build for clone. Should be ok
Linux CentOS7:
Same error message I got and after installation git in same machine were Jenkins installed, it is solved.
yum install git
Then you need to follow below steps. Hope so this may be useful for you to resolve your problem.
If your master is linux machine and slave is windows machine...
Pre-Requisites:
your slave machine should have same java version(jdk 1.8).
Git should be installed on your slave machine.
Steps to follow:
Go to your Windows slave configuration Manage Jenkins > Manage Nodes
Select your slave configuration
Check Tool Locations under Node Properties
Enter complete path to git executable including git.exe
Tool Locations
Name: (GIT) git
Home: C:\Program Files (x86)\Git\cmd\git.exe
See screenshot:
1) Make sure the git.exe has executable permissions.
2) Make sure git is configured correctly to refer in Global Tool configurations and also on the Jenkins agent (windows in your case) where you running the job, environment variable for git.exe executable is set correctly
have this problem after my company move to 2FA (2 factory authentication) at GitHub
in the Jenkins I get in credential this
to fix it
I create a personal access token in Github from here
2)after that i get to the same place in the jenkins when the errors ->Credential->add ->jenkins
and get as you see in the picture down
username= what you want name
password = token that you get
Upgrading all plugins and Jenkins to 2.332.1 solved for me
This answer may sound like a joke, but it resolved the exact error message we were getting for only 1 pipeline:
Check if the pipeline has a parameter with no name value.
Don't forget to Add your deploy key credentials (the deploy key attached to the github project) in jenkins (http://yourjenkinsurl:8080/credentials/)

How Jenkins master instructs slave to download source from TFS

DevOps configured a windows slave machine as build machine for our team, and I noticed that he installed TFS plug in Jenkins master ,but not slave machine. However we do get source code in the slave afterwards.
I wonder how the download workflow works? :
1) Master downloads source code and then transfers code to slave
machine ?
2) or after Master connects to TFS server, then it just instructs slave machine to download it from TFS server directly?
Please explain a bit the mechanism. If it is 2), then what is installed in slave to be able to download from TFS.
VCS plugins usually work this way:
Master is configured to use some VCS and prepared with some settings
Slave has some binaries that are able to execute download command
After a build start, most steps will be executed on slave via its binaries, including downloading of source code. This requires slave to has VCS binary (for example, git) and access to target repository (for git it may be ssh key).
I don't have any slave with TFS at hand right now, but the process is pretty same. I suppose if you check Console output of build, you'll see the full path to binary used for TFS download somewhere at the very top.
Here is a sample of such output for git:
Building remotely on slave01 in workspace /jenkins-workspace
> /bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /bin/git config remote.origin.url git#github.com:ORG/repo.git # timeout=10
To establish a communication between Jenkins and TFS, you need to install Team Foundation Server Plugin and configure it as this article states. In this way, Jenkins can get resources from TFS.
Each slave runs a separate program called a "slave agent", the slave agent and Jenkins master needs to establish a bi-directional communication link.
To set up slaves/nodes in Jenkins, you can refer to this article. If all the settings all entered correctly, the node slave machine will be online and communicate with Jenkins master.

TeamCity hg build configuration calling hg init on repo change detected

In TeamCity 9 (windows) I have an existing hg repo that I would like to incorporate into a new TC project.
However I am getting an error when the build agent runs, suggesting that is trying to 'hg init' the repo.
The error message is :
"C:\code\xxxx\"}: 'hg init' command failed.
stderr: abort: repository . already exists! "
This seems like very basic configuration issue, I have performed this setup in older versions of TC..
Updated with more info as requested :
VCS root has a 'HG command path' of 'hg'
The latest build log is :
Build 'TestProject :: TestBuildConfig' #7
Started 'Tue Aug 04 12:26:18 BST 2015' on 'PCUKDZKBP32' by 'James (tcadmin)'
Finished 'Tue Aug 04 12:26:18 BST 2015' with status 'FAILURE Unable to collect changes'
TeamCity URL http://localhost:8090/viewLog.html?buildId=24&buildTypeId=TestProject_TestBuildConfig
TeamCity server version is 9.1 (build 36973)
[12:26:18]i: TeamCity server version is 9.1 (build 36973)
[12:26:18]E: bt2
[12:26:18] : Collecting changes in 1 VCS root
[12:26:18] : [Collecting changes in 1 VCS root] VCS Root details
[12:26:18] : [VCS Root details] "TestRoot" {instance id=20, parent internal id=2, parent id=TestProject_TestRoot, description: "mercurial: c:\code\TestProject\"}
[12:26:18]i: [Collecting changes in 1 VCS root] Loading current repository state for VCS root 'TestRoot'
[12:26:18]i: [Loading current repository state for VCS root 'TestRoot'] VCS root 'TestRoot': [C:\Windows\System32\config\systemprofile\.BuildServer\system\caches\mercurial\hg_4258089649368462685] hg init
[12:26:18]E: Failed to collect changes, error: 'hg init' command failed.
stderr: abort: repository . already exists!
[12:26:18] : Build finished
This is happening because the checkout directory already exists and is not being updated. I think the below solution should be all you need to get rid of this error.
In your TeamCity Configuration, redirect to the "Edit project build configurations" tab where you have set this build configuration.
In your build configuration click on the VCS tab on the left which will show you the attached VCS repositories to that configuration.
On this page there is a small CheckBox which says something like "clean all files before checkout/build" tick this and run your build and it should delete all the existing instances of the repository which was pulled down and download it again.
I have had a similar issue to this and it was driving me crazy. It was happening on two different fresh instances of TeamCity v9.1.1.
In the end I installed a fresh version of v9.0.4 and it worked successfully each time.
I plan to upgrade the instance to v9.1.1 today and see if the breaks. So it looks as though it may be an issue with TC itself.

Jenkins Error cloning remote repo 'origin', slave node

I need some help here, It's been a week I'm with this problem, can't figure out what's going on. I'm not able to clone a git repo from a slave node (Jenkins). I added the ssh key, host and slave (I've already tried generating a single key and one for each virtual and host)).
On Jenkins:
url:git#github.com: < repo>
Credentials: Here I tried with username/password, username with ssh file, username with ssh key directly, and -none-.
It doesn't seems like there is an authentication problem since I can clone the repo manually from console (both, slave and host). I can also connect with
ssh -T git#github.com
so the ssh key is fine, but when I build, this appear on console:
Building remotely on IE10Win7 in workspace C:\Users\IEUser\Desktop\<
folder >
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository git#github.com:< repo>.git
git init C:\Users\IEUser\Desktop\< folder> # timeout=10
ERROR: Error cloning remote repo 'origin'
ERROR: Error cloning remote repo 'origin'
Performing Post build task...
Does anyone have an idea? Hope someone can give me a clue, Thanks!
I fixed this problem by setting the slave node tool path, selecting git and setting its value to
C:\Program Files (x86)\Git\bin\git.exe
Location: Configure Node - Tool Locations
I recently updated several jenkins plugins and had this problem after the updates. Rolling back the git plugin didn't help, but I did a few other things to get it working. I listed all three here, but it was probably (2) that fixed the problem. Apparently the git executable was reset to default. So, configuring the git executable within the specific project was probably all that was needed. However the other items might come in handy too.
(1) The default git on a jenkins linux install geenrally points to /usr/lib... You need to specify a separate GitForWindows that points to the windows version:
Manage Jenkins
Configure System
Under Git - Git Installations
Add Git -> Git
Give it a name to be referenced in projects
(mine is WindowsGit)
Set Path to Git Executable
(mine is "C:\Program Files (x86)\Git\bin\git.exe")
(for recent git the path is "C:\Program Files\Git\bin\git.exe")
(2) Configure git on the specific project:
Select the project
Select Configure
Under Source Code Management - Git
Select Git Executable as configured in 1)
Set credentials or add new (ssh keys, etc)
(3) Updating the jenkins slave service to run as a specific user:
Go to Windows Services on the slave -- StartMenu, type "services"
Select the Jenkins Slave service in the list on the right
Right-click and select "Properties" of the Jenkins Slave service
Select the "Log On" tab
Update the username and password used in manual tests
Domain login can be specificied with <DOMAIN>\<USERNAME>
Local logins just use <USERNAME>
OK to save and exit
Right-click again and select "Restart" to make the changes active.
I found a decent workaround in my case. The git clone command always inherits its process owner, which may make a difference, even if the two owners of Jenkins (SYSTEM) and cmd (USER) seem to have the same rights on your system. All other configurations were identical (keys, knownhosts, Git client version).
So as far as I can see, calling git clone from cmd will succeed because it calls the remote as USER, whereas git clone called from Jenkins may be rejected because it calls the remote as SYSTEM. In Services, where you would typically start Jenkins through the GUI, you can configure the service to run as a different user (right click on service --> Properties --> Log On). I had to put it like USER#DOMAIN, e.g. Jenkins#company.local or so. I'm not sure about how a cmd parameter would look, but I'd expect there to be one.
Also, I don't quite know what difference this workaround makes in the end, because on my Jenkins, SYSTEM and USER are configured to have the same rights across the system and they are of course both recognized as "Jenkins" by remote. Still, it does the trick for me. Deeper insights welcome.
I was facing similar problem and found that I need to add git to my PATH environment variable for a Windows based slave. I think that #dhj suggestion 2 might work as well in this case.
I found this workaround on Jenkins Jira.
In my case, I started getting this exact error after updating Git on some of my build machines (via Chocolatey, using the "git.install" package) from 1.9.4 to 2.5.0. The old 1.9.4 install was a 32-bit package but the new one is a 64-bit one, so the default install location switched from C:\Program Files (x86)\Git to C:\Program Files\Git. I had the 64-bit path configured on the Jenkins master (since it had the newer Git version), but some slaves still had the older 32-bit version installed, so the slaves were attempting to use an incorrect path. I could have overridden the Git path for individual slaves but the cleaner solution for me was simply to upgrade all the slaves to the newer 64-bit version.
I tried most of the above:
Specify git location.
Set service user.
Run as Administrator.
None of it worked. Eventually decided to uninstall git64 and install git32... changed the git path to the new location (in x86 Program Files). And everything worked.
I ran into this issue recently.
We had some items in our PATH EV which we had added when trying to connect Winium and Selenium to our Jenkins instance.
We removed these items, but still Jenkins seemed to be holding on to the values. After a bit of troubleshooting: restarting Jenkins; restarting the Jenkins server; setting the EVs at the node level; etc., we restarted the Jenkins JNLP service on the Windows slave.
And they lived happily ever after.
I also got the same error and fixed by adding a git path in the "Manage Jenkins -> Global Tool Configuration".
In my env, The windows Jenkins master run a job on the ubuntu slave machine, the master machine has used the default git ('C:\Program Files\Git\git.exe') path and the slave machine has used the git ('/usr/bin/git') path, therefore, I configured slave git path into the master configuration '/usr/bin/git' and its start working for me

Location of Git Executable for Jenkins on Windows

Which is the correct installation directory for Jenkins to use? Here are the options I have tried and the results I have seen.
C:\Git\bin\git.exe
C:\Git\cmd\git
same as above
C:\Git\cmd\gitk.cmd
If I continue and ask the job to build here is the console output.
Started by an SCM change
Building in workspace C:\Jenkins\workspace\git_test
Checkout:git_test / C:\Jenkins\workspace\git_test - hudson.remoting.LocalChannel#12f2468
Using strategy: Default
Cloning the remote Git repository
Cloning repository ssh:///jenkins#xxxx.yyyyyyyyy.com:test.git
git --version
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
Fetching upstream changes from origin
Seen 0 remote branches
No candidate revisions
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
Since they all result in one error or another its not clear which one is correct.
This is not a problem with git not being found but that putty has not yet been told that it can trust the ssh-key presented by the repository sshd server.
Run a manual git command first on the Jenkins server, so you can say yes to accept the host key, and then try again.

Resources