Configure Clouds
Remote FS root: /home/ec2-user
Remote user: ec2-user
Labels: OnDemand
Test connection: Success.
EC2 plugin can successfully provision an EC2 instance and start the Jenkins slave if the Jenkins' project does not use git. If I use git, I got,
Error:
java.io.IOException: Cannot run program "git" (in directory "/home/ec2-user/workspace/demo1"): error=2, No such file or directory
Project Configuration
Restrict where this project can be run
Label Expression: OnDemand
Source Code Management
Git
Repositories Repository URL: Some URL
Credentials: Some Credentials
git init /home/ec2-user/workspace/demo1 # timeout=10
ERROR: Error cloning remote repo 'origin'
java.io.IOException: Cannot run program "git" (in directory "/home/ec2-user/workspace/demo1"): error=2, No such file or directory
Use jGit (Jenkins git client plugin). It solves the problem.
Related
When I execute my Jenkins pipeline, during the repository clone stage, it crashes and the error message is:
Failed to start websocket connection io.fabric8.kubernetes.client
Not sure if it's because of the way I am cloning the repo or a VPN issue (as I am working on a company laptop which uses a company VPN).
Changed the way I cloned the repo, used both HTTP and SSH. Currently I am cloning the repo like this in the pipeline: sh "git clone -b BRANCH_NAME REPO_URL"
I am trying since awhile to setup an Azure Pipeline to access our internal TFS 2018 server.
I created an "Other Git" Service Connection named: TFS_PRJ, I used this intranet URL: https://tfs.mycie.com/DefaultCollection/myProject/.
For the authentication, I tried, my Windows domain account credentials as well as a PAT Token created in TFS with all access rights.
When I created the pipeline, I specified my self-hosted agent located on the same intranet and the master branch. Does this branch have an impact when accessing TFS? I can see in the logs: "Starting: Checkout TFS_PRJ#master to s". I don't see branches in TFS, should I create something in TFS to make it work?
When running the pipeline, I first have a timeout
Then it runs and after 6-7 minutes, logs shows this error: fatal: unable to access 'https://tfs.myCie.com/DefaultCollection/myProject/': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to tfs.myCie.com:443
I understood that to access this server, the agent should not use the proxy that is currently used in pipelines accessing GitHub. This bypass is usually done by using a proxy.pac file but I don't see how to use this file in agent configuration. To enable the proxy bypass with agent files, the .proxy file contains: http://abs-proxy.myCie.com:443 and the .proxybypass file contains: myCie.com
To test that the TFS server is accessible, I logged onto the agent server as the service account and in the IE Internet options, I added *.myCie.com to the trusted sites and then I was able to access https://tfs.mycie.com/DefaultCollection/myProject/. I am also able to ping the tfs.mycie.com server
So, I have several questions:
The branch part, is it normal to use the master branch while there is no branch in TFS or does it need something more?
When I run the pipeline, it gives a timeout as it can't connect to TFS but what account and what proxy does it try to use at this point? The one defined in the service connection?
About the SSL_ERROR_SYSCALL error, is it my syntax of the .proxybypass file that is wrong? "myCie.com", do you see anything thing else that could be done ?
Can there be some settings or access rights on the TFS server that I need to have or set ?
Update 1:
Thank you for this.
I created a YAML file in a Azure Repos with this content:
trigger:
- none
pool:
name: 'myAgent'
steps:
- checkout: none
- task: CmdLine#2
inputs:
script: 'git clone -b master https://tfs.myCie.com/DefaultCollection/myProject'
Which returned:
Cloning into 'myProject'...
fatal: could not read Username for 'https://tfs.myCie.com': terminal prompts disabled
I should probably try with the PATToken in the URL...
On the agent, I added the Git folder of the agent to the path and ran:
git clone https://anything:PATTokenToMyLogin#tfs.myCie.com/defaultcollection/myProject
Which returned:
Cloning into 'myProject'...
fatal: Authentication failed for 'https://tfs.myCie.com/defaultcollection/myProject/'
Then I tried to clone it from the Team Explorer in VS2019.
I have found two lists of projects, tfs.myCie.com and "local Git repositories", I couldn't clone projects from tfs.myCie.com so I tried to clone in the local Git but it didn't worked, not sure it was the thing to do either...
I took this screenshot, could it be my TFS project that is not suited for this ?
If you do not have other branch in TFS, it is normal to use the master branch, also we can specify branch name in the Get sources tab, please check the pic below.
You could check the service connection in the project settings->Service connections. It accesses the TFS repo via service account, such as below.
According to the error message OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to : It seems to be an issue in your network settings, maybe a proxy or a firewall blocking access to the remote repository.
You should check if your TFS server is behind the firewall or a proxy. If so, please turn it off and try again. Please also try running the clone command in a local machine directly to clone the affected repository to check if that works. If the server is behind a proxy, please try to set git configs for proxy something like this : git config --global http.proxy myproxy.com:8080
You need configure the service account permission in the TFS Version Control.
Update1
Please check the sample, I disable the checkout step and add cmd to clone TFS 2018 repo, then publish it to Artifacts to check the content.
Note: The repo will save in the self-hosted agent folder, we could add task Power shell at the end and call script to delete the repo folder.
trigger:
- none
pool:
name: Default
steps:
- checkout: none
- task: CmdLine#2
inputs:
script: 'git clone -b {branch name} {TFS repo URL}'
- task: CopyFiles#2
inputs:
SourceFolder: '$(Agent.BuildDirectory)'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
Result:
Update2
It’s mainly caused by the credentials have been remembered by Credential Manager. You should remove the credentials for https://tfs.myCie.com which have been stored in Credential Manager.
you can open Credential Manager -> Windows Credentials -> under Generic Credentials -> remove the credentials like git:https://tfs.myCie.com
In addition, please also delete the Visual Studio cache.
Note: You could also try to clone repo on a new machine.
I have acreated a simple jenkins project and on build section, I use a shel bash script (execute shell) as follow:
cd /home/ubuntu
git clone https://github.com/Bazarganigilani/AppEngineCron.git
mvn clean install
However , when I built my project I face
+ cd /home/ubuntu
+ git clone https://github.com/Bazarganigilani/AppEngineCron.git
fatal: could not create work tree dir 'AppEngineCron': Permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE
When I ssh to the node having this jenkins I can git clone in my /home/ubuntu directory but not through jenkins?
Is there a better way to avoid clone and make my jar somewhere in the jenkins node?
Seems like Jenkins is running with different user (other than UBUNTU). Mostly Jenkins will run with Jenkins user. So Jenkins user may not have permissions to create directory in /home/ubuntu.
Possible Solution: give /home/ubuntu folder access to the user which is running Jenkins
I installed Ansible plugin in Jenkins and I configured.
I created ansible.cfg, hosts and the playbook files.
I pushed those files with directory in Bitbucket.
The issue is when I start a build in Jenkins it says "skipping: no hosts matched" or I have already tested the directory manually and it works.
This is jenkins configuration:
This the error message:
When i execute the ansible-playbook command directly from the folder in Desktop it works.
This is when i executed the command in the jenkins directory
I think you need to provide a credentials owner. When you run it manually you are identified (with an attached ssh key) but Jenkins needs some permissions.
I have a Jenkins server setup with two jobs
first job polls the develop branch and builds the project on the jenkins server. i then have another job that polls the production branch this builds this branch on another jenkins slave which is the staging server. This job is configured so that on a successful build it should publish the artefacts over ssh to the production server.
All the SSh keys are setup and the staging server connects to production server but 0 files are transferred
using GIT_SSH to set credentials Bitbucket Repo
using .gitcredentials to set credentials
Checking out Revision 89874cc01a9f669df69817b1049b1ab98ecb19d3 (origin/Production)
SSH: Connecting from host [nginx-php-fastcgi]
SSH: Connecting with configuration [AmazonAWS] ...
SSH: Disconnecting configuration [AmazonAWS] ...
SSH: Transferred 0 file(s)
Finished: SUCCESS
I checked the staging workspace and files are being built there, just not sent to the prod server. Any suggestions??
i have also tried a different remove prefix as suggested bellow and here Jenkins transferring 0 files using publish over SSH plugin
You should remove /* from the Remove prefix line
Edit:
Your Source files cannot be outside of the job's workspace. If your files are in the root of workspace, just set it to * to transfer all workspace files, or **/* to include subdirectories. Else specify a pattern relative to ${WORKSPACE}.
Even adding a leading / will not escape that, as all it does is append that to workspace, in your case it becomes ${WORKSPACE}/var/www/workspace/opms-staging-server. Even using parent directory ../ will not work. This is for security concerns, else a job configurer could transfer private files off the Jenkins server.
If you need to get files from another job, you need to use Copy Artifacts build step. Tell me if that's your case, and I will explain further.