Everytime I try to build a Maven project hosted on a gitlab server with TeamCity, I get an error from the buildAgent. Both TeamCity and GitLab are on the same server.
It seems that the agent can't connect to gitlab but it does, because when I have to specify the pom.xml path in the build configuration section, I can navigate through the repository folders(http://prntscr.com/i8pyjf).
I have already tried different solutions:
I added both the root ssh and the ssh key of the ser that is running teamcity, both of them seem to work cause the test connection was succesful(http://prntscr.com/i8q0jf);
I added teamcity.git.use.native.ssh true in the buildAgent conf and the error log changed a little (the error is still the same but I get less lines)
I added teamcity.git.use.native.ssh true as a configuration parameter -> http://prntscr.com/i8pnqp (not sure if I did it right)
I tried adding the runAs plugin to force the user agent to use root
TeamCity version -> TeamCity Professional 2017.2.2 (build 50909)
Here's the error log:
[22:03:51] The build is removed from the queue to be prepared for the start
[22:03:51] Collecting changes in 1 VCS root
[22:03:51] [Collecting changes in 1 VCS root] VCS Root details
[22:03:51] [VCS Root details] "git#151.80.136.106:Developer/BanlogBridge.git" {instance id=11, parent internal id=1, parent id=Ban_Git15180136106DeveloperBanlogBridgeGit, description: "git#151.80.136.106:Developer/BanlogBridge.git#master"}
[22:03:51] [Collecting changes in 1 VCS root] Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] Upper limit revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] Cannot find modification with revision 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] No modification from VCS root is attached to build configuration, use upper limit revision
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] Computed revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51] Starting the build on the agent Default Agent
[22:03:52] Clearing temporary directory: /usr/local/teamcity/buildAgent/temp/buildTmp
[22:03:52] Publishing internal artifacts
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[22:03:52] Using vcs information from agent file: db80d9c7294729d5.xml
[22:03:52] Checkout directory: /usr/local/teamcity/buildAgent/work/db80d9c7294729d5
[22:03:52] Updating sources: auto checkout (on agent)
[22:03:52] [Updating sources] Will use agent side checkout
[22:03:52] [Updating sources] VCS Root: git#151.80.136.106:Developer/BanlogBridge.git
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] Git version: 2.7.4.0
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] Will use native ssh (teamcity.git.use.native.ssh=true)
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git config core.sparseCheckout true
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git show-ref
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git show-ref refs/remotes/origin/master
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] Commit '0d41a12c788798152c7da9327ef63b759f7d5b4c' is not found in local clone. Running 'git fetch'...
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git fetch --progress origin +refs/heads/master:refs/remotes/origin/master
[22:03:52] [Updating sources] Failed to perform checkout on agent: '/usr/bin/git fetch --progress origin +refs/heads/master:refs/remotes/origin/master' command failed.
exit code: 128
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
[22:03:52] Publishing internal artifacts
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[22:03:52] Build failed to start. Artifacts will not be published for this build
[22:03:52] Build finished
Thank you for your help!
It happens because known hosts database on the TeamCity agent machine doesn't contain the fingerprint of the Gitlab server. You can add it by running some command via ssh, e.g. git ls-remote <your repository url>, and agree to add the fingerprint if it's correct.
Actually TeamCity checks out code with known hosts database check disabled. Please check if you have anything related to Gitlab in the .ssh/config on the TeamCity agent machine.
Related
So I have one job that produces artifacts, and another job with dependency on those artifacts from first job. I tried to use SSH Upload, however I inserted into field "Paths to sources" *.deb => /tmp
In order to download Debian packages from previous job to tmp, but it does not download anything
Logs from my job to deploy:
[21:54:49] Collecting changes in 1 VCS root
[21:54:54] The build is removed from the queue to be prepared for the start
[21:54:54] Starting the build on the agent "agent3"
[21:54:55] Updating tools for build
[21:54:55] Clearing temporary directory: /opt/buildagent/temp/buildTmp
[21:54:55] Publishing internal artifacts
[21:54:55] Full checkout enforced. Reason: [Checkout directory is empty or doesn't exist]
[21:54:55] Will perform clean checkout. Reason: Checkout directory is empty or doesn't exist
[21:54:55] Checkout directory: /opt/buildagent/work/245575fe8c01221b
[21:54:55] Resolving artifact dependencies
[21:54:55] [Resolving artifact dependencies] Destination directory [/tmp] cleaned
[21:54:55] [Resolving artifact dependencies] Downloading files from <Xenoss.test / Build job of deb/rpm packages, build #0.0.2 [id 15836]> for pattern [*.deb => /tmp
*.rpm => /tmp]
[21:54:55] [Resolving artifact dependencies] 2 files retrieved
[21:54:55] Step 1/1: Upload deb/rpm package to destination server (SSH Upload) (1s)
[21:54:55] [Step 1/1] Permanently added '139.59.178.103' (EDDSA) to the list of known hosts.
[21:54:56] [Step 1/1] Starting upload via SCP to host [139.59.178.103:22]
[21:54:56] [Step 1/1] Uploaded [0] files for [] pattern
[21:54:56] Publishing internal artifacts
[21:54:56] [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[21:54:56] [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisherImpl]
[21:54:56] Build finished
You should to fix your artifact dependency rule. In your setup:
TeamCity downloads artifacts to /tmp directory
TeamCity tries to upload *.deb from directory folder which is not equal to /tmp
So correct artfact dependency rule should look like this:
*.deb => .
I am new to Jenkins and don't have much luck. I am trying to build my spring boot application with maven in it. It builds succesfully until I add commands "clean compile package" in Invoke top-level Maven targets.
The build fails.
Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /var/jenkins_home/jobs/sample/workspace
The recommended git tool is: NONE
No credentials specified
> git rev-parse --resolve-git-dir /var/jenkins_home/jobs/sample/workspace/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/rshncp/stackApp.git # timeout=10
Fetching upstream changes from https://github.com/rshncp/stackApp.git
> git --version # timeout=10
> git --version # 'git version 2.30.2'
> git fetch --tags --force --progress -- https://github.com/rshncp/stackApp.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/main^{commit} # timeout=10
Checking out Revision 497d77eeef33f9cc19c5390d21cf49e90ac24e05 (refs/remotes/origin/main)
> git config core.sparsecheckout # timeout=10
> git checkout -f 497d77eeef33f9cc19c5390d21cf49e90ac24e05 # timeout=10
Commit message: "first commit"
> git rev-list --no-walk 497d77eeef33f9cc19c5390d21cf49e90ac24e05 # timeout=10
[workspace] $ mvn clean compile package
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
Caused: java.io.IOException: Cannot run program "mvn" (in directory "/var/jenkins_home/jobs/sample/workspace"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:995)
at hudson.Launcher$ProcStarter.start(Launcher.java:507)
at hudson.Launcher$ProcStarter.join(Launcher.java:518)
at hudson.tasks.Maven.perform(Maven.java:367)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:806)
at hudson.model.Build$BuildExecution.build(Build.java:198)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
at hudson.model.Run.execute(Run.java:1888)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:99)
at hudson.model.Executor.run(Executor.java:431)
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
How can I fix this?
Download Maven as plug-in. You must go to Jenkins Global Tool Configuration, and configure a Maven version with automatic installer (from the web).
Setup in global configuration, maven version. Look second answer of this case Cannot run program "mvn" error=2, No such file or directory
We are getting a Access Denied error while trying to checkout on one of our teamcity Agents. The other agent is able to checkout and build fine.
I added this property teamcity.git.use.native.ssh=true and checked if the teamcity user has all same permissions as the other agent and tried removing the .git file under system\git*. None of these worked.
Attaching the log file and screenshot.
Log File
[09:17:25] : Collecting changes in 1 VCS root
[09:17:25] : [Collecting changes in 1 VCS root] VCS Root details
[09:17:25] : [VCS Root details] "Generic Git VCS Root" {instance id=512, parent internal id=44, parent id=GenericGitVcsRoot, description: "http://*****/tfs/SMI-RPS/RPSMain/_git/cmp#refs/heads/master"}
[09:17:26]i: [Collecting changes in 1 VCS root] Detecting changes in VCS root 'Generic Git VCS Root' (used in 'Development Insights', 'Publish Package To Octopus')
[09:17:26]i: [Collecting changes in 1 VCS root] Will collect changes for 'Generic Git VCS Root' starting from revision cfd2c37103f4c71213bf9ffd2700381ac67e038f
[09:17:26] : [Collecting changes in 1 VCS root] Compute revision for 'Generic Git VCS Root'
[09:17:26] : [Compute revision for 'Generic Git VCS Root'] Upper limit revision: cfd2c37103f4c71213bf9ffd2700381ac67e038f
[09:17:26]i: [Compute revision for 'Generic Git VCS Root'] MaxModId = 22287
[09:17:26] : [Compute revision for 'Generic Git VCS Root'] Latest commit attached to build configuration (with id <= 22287): cfd2c37103f4c71213bf9ffd2700381ac67e038f
[09:17:26] : [Compute revision for 'Generic Git VCS Root'] Computed revision: cfd2c37103f4c71213bf9ffd2700381ac67e038f
[09:17:26] : The build is removed from the queue to be prepared for the start
[09:17:26] : Starting the build on the agent "****"
[09:17:27]i: Agent time zone: America/***
[09:17:19]i: Agent is running under JRE: 1.8.0_121-b13
[09:17:19] : Updating tools for build
[09:17:19] : [Updating tools for build] Found 1 tool used by the build: NuGet.CommandLine.3.4.4
[09:17:19] : [Updating tools for build] All used tools are up-to-date
[09:17:19] : Clearing temporary directory: D:\TeamCity\buildAgent\temp\buildTmp
[09:17:19] : Publishing internal artifacts (4s)
[09:17:24] : [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[09:17:24] : [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[09:17:19] : Clean build enabled: removing old files from D:\TeamCity\buildAgent\work\3b5eca5f1ef307d3
[09:17:19] : Checkout directory: D:\TeamCity\buildAgent\work\3b5eca5f1ef307d3
[09:17:19]E: Updating sources: auto checkout (on agent) (1m:01s)
[09:17:19] : [Updating sources] Will use agent side checkout
[09:17:19]W: [Updating sources] VCS Root: Generic Git VCS Root (1m:01s)
[09:17:19] : [VCS Root: Generic Git VCS Root] revision: cfd2c37103f4c71213bf9ffd2700381ac67e038f
[09:17:19] : [VCS Root: Generic Git VCS Root] Git version: 2.15.0.0
[09:17:19] : [VCS Root: Generic Git VCS Root] Will use native ssh (teamcity.git.use.native.ssh=true)
[09:17:19]W: [VCS Root: Generic Git VCS Root] Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git) (1m:01s)
[09:17:19] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" config http.sslCAInfo
[09:17:19] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" config --unset http.sslCAInfo
[09:17:19] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" show-ref
[09:17:20]W: [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] Failed to list remote repository refs, outdated local refs will not be cleaned
[09:17:20] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" show-ref refs/remotes/origin/master
[09:17:20] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" show-ref refs/heads/master
[09:18:20] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" init --bare
[09:18:20] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" config http.sslCAInfo
[09:18:20] : [Update git mirror (D:\TeamCity\buildAgent\system\git\git-299ED72F.git)] "C:\Program Files\Git\bin\git.exe" config --unset http.sslCAInfo
[09:18:20]E: [Updating sources] Failed to perform checkout on agent: java.io.IOException: Access is denied
[09:18:20] : Publishing internal artifacts
[09:18:20] : [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[09:18:21] : [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[09:18:20] : Build failed to start. Artifacts will not be published for this build
[09:18:30] : Build finished ```
There could be a lot of causes of this error. A few ideas:
Is the TeamCity agent service running as the same user on both agents?
Are the folder permissions the same on both agents?
Does the checkout work if you use server side checkout instead of agent side?
Is it possible that somebody has a file / folder open on the agent causing a file lock?
I use maven to create releases using gitflow-maven-plugin. My projects builds fine, unless I create a release calling the following maven command
mvn -B gitflow:release
This fails with the following error
[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.9.0:release (default-cli) on project test:
release: Remote branch 'origin/master' is ahead of the local branch 'master'.
Execute git pull. -> [Help 1]
There are no changes on the master so there should be no such error, especially also cause the plugin does a fetch beforehand as shown in the log
16:03:21 [INFO] Fetching remote branch 'origin master'.
16:03:21 [INFO] Comparing local branch 'master' with remote 'origin/master'
Any clue what could cause that?
When I downloaded the workspace zip archive to inspect the cause of this problem, git showed that that master branch was indeed behind the remote master.
In the Jenkinsfile I only did
git checkout develop && git pull --rebase
I fixed the problem by pulling the master branch, too
git checkout master && git pull --rebase
git checkout develop && git pull --rebase
Probably a git fetch also would have sufficed
I have been having issues getting my new OpenShift Jenkins CI Server to work. I setup everything the way all tutorials tell me to, but when I try to build the project, I always get this same error:
Checking out Revision 3e88dcb5295354f9b02ef69ded84c97562c39aad (origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 3e88dcb5295354f9b02ef69ded84c97562c39aad
> git rev-list 3e88dcb5295354f9b02ef69ded84c97562c39aad # timeout=10
Parsing POMs
ERROR: Failed to parse POMs
java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:330)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler$AcceptorImpl.<init>(AbstractMavenProcessFactory.java:210)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler.call(AbstractMavenProcessFactory.java:196)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler.call(AbstractMavenProcessFactory.java:194)
at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:266)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:778)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
at hudson.model.Run.execute(Run.java:1741)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Finished: FAILURE
I am using Maven 3.3.9 and have made sure that all permissions are correct. This is a fresh install of OpenShift Jenkins with the only changes being adding JDK 7u79, GitHub plugin (including updating all dependencies for it) and adding Maven 3.3.9, however it is denied permission to the POM making it unable to be read.
I have seen this question OpenShif jenkins: java.net.BindException: Permission denied
However the link provided in the answer is outdated and no longer present, simply redirecting me to the documentation which does not help.
How can I allow my Jenkins server permission to allow it to parse the POM file and build my code?
Check your jenkins configuration :
scm Plugins
jenkins->configure system