SONAR_HOST_URL not reachable in bitbucket pipeline sonarqube - sonarqube

I am trying to integrate the sonarqube to bitbucket pipeline, and have following code there
- pipe: sonarsource/sonarqube-scan:1.0.0
variables:
SONAR_HOST_URL: ${SONAR_HOST_URL}
SONAR_TOKEN: ${SONAR_TOKEN}
- pipe: sonarsource/sonarqube-quality-gate:1.0.0
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
and I am getting error
SonarQube server [$SONAR_HOST_URL] can not be reached
I first tried setting localhost:9000, which is running at my local server, got this error, then I give website url, still getting same error,
what should I give SONAR_HOST_URL
Any help,
Thanks,

SonarQube server [$SONAR_HOST_URL] can not be reached
means SONAR_HOST_URL is not defined in the CI environment. You want to use Repository settings -> Repository variables to add both host url & token (ensure Secured check box is set for token).
P.S. The host url should be publicly accessible. It won't work for localhost:9000 because the Bitbucket CI has not\ way to connect to the instance of the sonarqube server running on your local dev box.

Related

What is the right host url in sonar for bamboo(plugin) configuration?

I have to set host url in sonar for bamboo(bambo plugin) configuration.
While my local docker program is running sonarqube container, it is confused to use localhost:9000 at host url in app configuration.
The error message is saying An error occurred while connecting the given SonarQube server: localhost:9000 failed to respond.
What should I do? Am I doing wrong or Is there anything to set more thing?
enter image description here
As your SonarQube instance is running in a different server, you need to point your "Sonar for Bamboo" plugin to that server, port 9000 (default of SonarQube). So, for example, if your server containing the SonarQube instance has the IP address 192.168.15.1 in your network, you need to configure the plugin to http://192.168.15.1:9000.
I did it in my environment and it works perfectly.

SSH timeout error on Azure DevOps CD pipeline

I am getting an timeout error when trying to deploy to an VM instance hosted on AWS. Manually I can log ing using
ssh -i myKeyFile.pem myuser#IP
Once I accessed the remote machine I can execute some docker commands and everything works fine. But now that I need to automated that on the CD pipeline is where I am getting the following error:
2020-06-02T21:37:12.6877276Z Trying to establish an SSH connection to ***#IP:port
2020-06-02T21:38:52.4629461Z ##[error]Failed to connect to remote machine. Verify the SSH service connection details. Error: Error: Timed out while waiting for handshake.
2020-06-02T21:38:52.4685976Z ##[section]Finishing: Run shell commands on remote machine
The steps I follow to make the SSH connection are:
I created a SSH service connection on the project settings in Azure DevOps
I created the CD pipeline
I added a SSH task with the following parameters
When I manually trigger it to test if it works, the release start working fine but after 1:43 minutes more or less is when I got the error:
Then, when I review the logs, it is the same error I pasted at the beginning:
[error]Failed to connect to remote machine. Verify the SSH service connection details. Error: Error: Timed out while waiting for handshake
I've increase the handshake timeout settings from the default one (20000) to 90000, but no luck.
Any one has face this problem before?
Seems there is an ongoing error with the default agent pools from Azure DevOps. Lot of people have been reported this and Azure DevOps teams is working on it at the time this post is been written (I couldn't find the post where all that is details. I will add this later on).
The workaround is
To create a self-hosted agent.
After this has been created you will need to re-create your CD pipeline using the new self-hosted agent.
The rest of the SSH task configuration depends on your needs. But if you want to test the SSH connection works, just print something:
echo 'I'm connected'
After this you CD pipeline should be working fine.
More details on how to created the Self-Hosted Agent on Windows. There are also links for Linux and Mac.
I had a similar issue with a VM in Azure. It turned out I had set the security group to only allow SSH in from my local network and Azure Dev-Ops agents obviously run in a Microsoft network and were coming from a different IP Address range. The solution was to open up SSH to all source IP Addresses. You can get the list of IP address ranges Dev-Ops agents use but they appear to change every week which isn't very helpful.
See https://learn.microsoft.com/en-us/azure/devops/organizations/security/allow-list-ip-url?view=azure-devops#microsoft-hosted-agents

Jenkins build project "Unable to access to repository"

I am a complete Jenkins noob so if I have missed something completely obvious I apologise in advance!
I am building an intranet web application using Visual Studio 2010 and commit changes using AnkhSVN to a repository stored on a server that is running Visual SVN Server.
Due to budget restrictions this server is also acting as our web server and also running Jenkins. It is connected to our internal network but doesn't have external internet access so I have had to manually install Jenkins plugins and dependencies.
I am trying to build a Jenkins project that would build the web application when it detects a commit but when I enter the repository URL and the user credentials in the source code management window I get the following error message:
Unable to access to repository
However when I enter the url in a browser and enter the same credentials I can access the repository without any errors.
Any ideas would be greatly appreciated.
Server Specs
Windows Server 2012 R2 Datacenter 64bit
Visual SVN Server
Port: 443
Version 3.5.6
Jenkins
Port: 8080
Credentials Plugin 2.1.9
MapDB API Plugin 1.0.9.0
Pipeline: SCM Step 2.3
Pipeline: Step API 2.5
SCM API Plugin 1.3
SSH Credentials Plugin 1.12
Structs Plugin 1.5
Subversion Plug-in 2.7.1
check if the ip of jenkins server can access the svn ip server....i have the same problem and i found that my ci server can not access the svn server .using ping command
That actually might be okay. For some reason I see similar error message (could be a bug in Jenkins frontend) when edit SCM details for a job in Jenkins, but it does work flawlessly if I actually save and run the job.
Give it a try it might actually work during the build time.

Starting Bitbucket Server in Ansible

I'm using Vagrant and Ansible to create my Bitbucket Server on Ubuntu 15.10. I have the server setup complete and working but I have to manually run the start-webapp.sh script to start the server each time I reprovision the server.
I have the following task in my Bitbucket role in Ansible and when I increase the verbosity I can see that I get a positive response from the server saying it will be running at http://localhost/ but when I go to the URL the server isn't on. If I then SSH in to the server and run the script myself, getting the exact same response after running the script I can see the startup webpage.
- name: Start the Bitbucket Server
become: yes
shell: /bitbucket-server/atlassian-bitbucket-4.7.1/bin/start-webapp.sh
Any advice would be great on how to fix this.
Thanks,
Sam
Probably better to change that to an init script and use the service module to start it. For example, see this role for installing bitbucket...
Otherwise, you're subject to HUP and other issues from running processes under an ephemeral session.

Sonar Runner 404 localhost

I'm trying to get Sonar working locally on an OS X box to do some proof of concept work, I've downloaded the following:
Sonar Qube: 4.5.6
Sonar Runner: 2.4
Sonar Qube is configured as:
sonar.web.host=localhost
sonar.web.context=/sonar
sonar.web.port=9000
When I try and use Sonar Runner with one of the example projects I get the following error:
ERROR: Error during Sonar runner execution
ERROR: Fail to request server version
ERROR: Caused by: Status returned by url : 'http://localhost:9000/sonar/api/server/version' is invalid : 404
If I copy and paste the URL from the console into the browser then the page loads (displaying 4.5.6).
What could be causing the script to receive a 404?
The box is behind a proxy but nothing should be trying to get to the outside world
UPDATE:
Changing the configuration from localhost to using the machines IP address produces a timeout rather than a 404, everything still works fine through the browser.
So it turned out my problem was that the JVM wasn't using the proxy settings of my machine, I had to add the following to the Sonar runner script.
SONAR_RUNNER_OPTS="-Dhttp.proxyHost=myproxy -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts=my.local.host"
It's possible that HTTP queries from sonar-runner are routed based on system proxy settings, while your browsers may use their own proxy settings.
Go check the system-wide setting:
System Preferences/Network/Advanced/Proxies/Bypass proxy settings for these Hosts & Domains
And make sure that localhost/127.0.0.1 is in there.

Resources