Solucionado (ver solução)

Importante

Você está vendo a versão anterior da nova experiência da Alura que estamos preparando para você. Em breve, ela ganha uma identidade visual novinha totalmente pensada em potencializar seus estudos!

Solucionado
(ver solução)
16
respostas

Build com problema !

Boa noite a todos.

Estou com um problema no meu Build após solucionar um problema no meu PhantomJS, pelo oque vejo no console parece ser um problema no Sonar.

[INFO] User cache: C:\Users\Renato\.sonar\cache
[ERROR] SonarQube server [localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:05 min
[INFO] Finished at: 2020-04-10T17:24:21-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project argentum-web: Unable to execute SonarQube: Fail to get bootstrap index from server: Expected URL scheme 'http' or 'https' but was 'localhost' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Chamar alvos Maven de alto nível' marked build as failure
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
[DeployPublisher][INFO] Build failed, project not deployed
Finished: FAILURE

Post da dúvida anterior

https://cursos.alura.com.br/forum/topico-problema-ao-fazer-o-teste-com-o-phantomjs-108315

16 respostas

Olá Renato, tudo bem? Como pensei no outro tópico, esse problema está ocorrendo porque o ele não está conseguindo encontrar servidor do SonarQube. Então você pode tentar seguir os passos mencionados na própria documentação do SonarQube. Onde é preciso abrir o arquivo sonar-scanner.properties que fica dentro da pasta conf do SonarQube, e deixar o arquivo com a seguinte configuração:

#----- Default SonarQube server
#sonar.host.url=http://localhost:9000

E também adicionar a pasta bin do SonarQube ao path do seu sistema operacional.

Fala pra gente o resultado!

Fala Jonilson, tudo bem irmão !

Bom cara, vamos por partes, verifiquei a documentação do sonar como você recomendou, configurei a pasta bin na minha variável de ambiente (igual faz com as configurações iniciais de JAVA_HOME), até ai tudo ok. Quando fui a pasta conf para ver o sonar-scanner.properties não encontrei esse arquivo, encontrei os arquivossonar-properties e wrapper.conf, de qualquer forme dei uma verificada e não encontrei o trecho de configuração que você mencionou acima irei colocar aqui em baixo o conteúdo dos dois arquivos. Mesmo com isso, reiniciei o sonar e ele está funcionando perfeitamente na porta 9000, mas quando rodo o Build apresenta o mesmo erro de antes.

sonar-properties

sonar-properties

# Property values can:
# - reference an environment variable, for example sonar.jdbc.url= ${env:SONAR_JDBC_URL}
# - be encrypted. See http://redirect.sonarsource.com/doc/settings-encryption.html

#--------------------------------------------------------------------------------------------------
# DATABASE
#
# IMPORTANT: the embedded H2 database is used by default. It is recommended for tests but not for
# production use. Supported databases are MySQL, Oracle, PostgreSQL and Microsoft SQLServer.

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
#sonar.jdbc.username=
#sonar.jdbc.password=

#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092
#----- MySQL 5.6 or greater
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported. It can not be changed.
#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance


#----- Oracle 11g/12c
# - Only thin client is supported
# - Only versions 11.2.x and 12.x of Oracle JDBC driver are supported
# - The JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/
# - If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
#sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521/XE


#----- PostgreSQL 8.x/9.x
# If you don't use the schema named "public", please refer to http://jira.sonarsource.com/browse/SONAR-5000
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar


#----- Microsoft SQLServer 2008/2012/2014 and SQL Azure
# A database named sonar must exist and its collation must be case-sensitive (CS) and accent-sensitive (AS)
# Use the following connection string if you want to use integrated security with Microsoft Sql Server
# Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
# For Integrated Security to work, you have to download the Microsoft SQL JDBC driver package from
# http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
# and copy sqljdbc_auth.dll to your path. You have to copy the 32 bit or 64 bit version of the dll
# depending upon the architecture of your server machine.
# This version of SonarQube has been tested with Microsoft SQL JDBC version 4.1
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true

# Use the following connection string if you want to use SQL Auth while connecting to MS Sql Server.
# Set the sonar.jdbc.username and sonar.jdbc.password appropriately.
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar


#----- Connection pool settings
# The maximum number of active connections that can be allocated
# at the same time, or negative for no limit.
# The recommended value is 1.2 * max sizes of HTTP pools. For example if HTTP ports are
# enabled with default sizes (50, see property sonar.web.http.maxThreads)
# then sonar.jdbc.maxActive should be 1.2 * (50) = 120.
#sonar.jdbc.maxActive=60

# The maximum number of connections that can remain idle in the
# pool, without extra ones being released, or negative for no limit.
#sonar.jdbc.maxIdle=5

# The minimum number of connections that can remain idle in the pool,
# without extra ones being created, or zero to create none.
#sonar.jdbc.minIdle=2

# The maximum number of milliseconds that the pool will wait (when there
# are no available connections) for a connection to be returned before
# throwing an exception, or <= 0 to wait indefinitely.
#sonar.jdbc.maxWait=5000

#sonar.jdbc.minEvictableIdleTimeMillis=600000
#sonar.jdbc.timeBetweenEvictionRunsMillis=30000



#--------------------------------------------------------------------------------------------------
# WEB SERVER
# Web server is executed in a dedicated Java process. By default heap size is 512Mb.
# Use the following property to customize JVM options.
#    Recommendations:
#
#    The HotSpot Server VM is recommended. The property -server should be added if server mode
#    is not enabled by default on your environment:
#    http://docs.oracle.com/javase/8/docs/technotes/guides/vm/serve

wrapper.conf

# Path to JVM executable. By default it must be available in PATH.
# Can be an absolute path, for example:
#wrapper.java.command=/path/to/my/jdk/bin/java
wrapper.java.command=java


#
# DO NOT EDIT THE FOLLOWING SECTIONS
#


#********************************************************************
# Wrapper Java
#********************************************************************
wrapper.java.additional.1=-Djava.awt.headless=true
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
wrapper.java.classpath.1=../../lib/jsw/*.jar
wrapper.java.classpath.2=../../lib/*.jar
wrapper.java.library.path.1=./lib
wrapper.app.parameter.1=org.sonar.application.App
wrapper.java.initmemory=3
wrapper.java.maxmemory=3

#********************************************************************
# Wrapper Logs
#********************************************************************

wrapper.console.format=PM
wrapper.console.loglevel=INFO
wrapper.logfile=../../logs/sonar.log
wrapper.logfile.format=M
wrapper.logfile.loglevel=INFO

# Maximum size that the log file will be allowed to grow to before
#  the log is rolled. Size is specified in bytes.  The default value
#  of 0, disables log rolling.  May abbreviate with the 'k' (kb) or
#  'm' (mb) suffix.  For example: 10m = 10 megabytes.
#wrapper.logfile.maxsize=0

# Maximum number of rolled log files which will be allowed before old
#  files are deleted.  The default value of 0 implies no limit.
#wrapper.logfile.maxfiles=0

# Log Level for sys/event log output.  (See docs for log levels)
wrapper.syslog.loglevel=NONE

#********************************************************************
# Wrapper Windows Properties
#********************************************************************
# Title to use when running as a console
wrapper.console.title=SonarQube

# Disallow start of multiple instances of an application at the same time on Windows
wrapper.single_invocation=true

#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
#********************************************************************
# WARNING - Do not modify any of these properties when an application
#  using this configuration file has been installed as a service.
#  Please uninstall the service before modifying this section.  The
#  service can then be reinstalled.

# Name of the service
wrapper.ntservice.name=SonarQube

# Display name of the service
wrapper.ntservice.displayname=SonarQube

# Description of the service
wrapper.ntservice.description=SonarQube

# Service dependencies.  Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=

# Mode in which the service is installed.  AUTO_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START

# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false

#********************************************************************
# Forking Properties
#********************************************************************
wrapper.disable_restarts=TRUE
wrapper.ping.timeout=0
wrapper.shutdown.timeout=3000
wrapper.jvm_exit.timeout=3000

Erro na saída do Build

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-pmd-plugin:3.6:pmd (default) @ argentum-web ---
[WARNING] Unable to locate Source XRef to link to - DISABLED
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.6.201602180812:report (default) @ argentum-web ---
[INFO] Analyzed bundle 'argentum-web' with 12 classes
[INFO] 
[INFO] --- maven-failsafe-plugin:2.19.1:verify (default) @ argentum-web ---
[INFO] 
[INFO] ----------------< br.com.caelum.argentum:argentum-web >-----------------
[INFO] Building argentum-web 1.0.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ argentum-web ---
[INFO] User cache: C:\Users\Renato\.sonar\cache
[ERROR] SonarQube server [localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:07 min
[INFO] Finished at: 2020-04-15T20:28:32-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project argentum-web: Unable to execute SonarQube: Fail to get bootstrap index from server: Expected URL scheme 'http' or 'https' but was 'localhost' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Chamar alvos Maven de alto nível' marked build as failure
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
[DeployPublisher][INFO] Build failed, project not deployed
Finished: FAILURE

Renato, você realizou o download de qual versão do SonarQube, porque como o instrutor mencionou é importante que seja utilizada a algumas das releases da versão 5, eu utilizei a versão 5.6.7 e conseguir executar normalmente, então se puder fazer o download e usar essa versão é só clicar no link abaixo:

SonarQube 5.6.7 (former LTS)

Depois de fazer o download, crie uma pasta com o nome sonarqube dentro do disco local "C:" e descompacte o arquivo baixado dentro dessa pasta C:\sonarqube. Agora você deve ir na pasta bin (dentro de C:\sonarqube), e entrar na pasta correspondente ao seu sistema operacional:

  • Entre na pasta windows-x86-32 caso seu sistema seja de 32bits.

  • Ou então entre pasta windows-x86-64 caso seu sistema seja de 64bits.

E por fim execute o arquivo StartSonar.bat. E depois tente realizar o Build novamente.

E fala pra gente o resultado!

Fala meu amigo, boa noite !

Então, eu baixei exatamente a mesma versão que você, porém não tinha descompactado a pasta no C: .Então, movimente a pasta para dentro do disco local e fiz o passo confirme você me explicou, e quando rodei o Build apresentou o erro abaixo. Antes de rodar o Build, eu acessei o sonar no localhost:9000 e funcionou normalmente. Oque será dessa vez ??

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-pmd-plugin:3.6:pmd (default) @ argentum-web ---
[WARNING] Unable to locate Source XRef to link to - DISABLED
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.6.201602180812:report (default) @ argentum-web ---
[INFO] Analyzed bundle 'argentum-web' with 12 classes
[INFO] 
[INFO] --- maven-failsafe-plugin:2.19.1:verify (default) @ argentum-web ---
[INFO] 
[INFO] ----------------< br.com.caelum.argentum:argentum-web >-----------------
[INFO] Building argentum-web 1.0.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ argentum-web ---
[INFO] User cache: C:\Users\Renato\.sonar\cache
[ERROR] SonarQube server [localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  55.448 s
[INFO] Finished at: 2020-04-16T20:19:32-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project argentum-web: Unable to execute SonarQube: Fail to get bootstrap index from server: Expected URL scheme 'http' or 'https' but was 'localhost' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Chamar alvos Maven de alto nível' marked build as failure
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
[DeployPublisher][INFO] Build failed, project not deployed
Finished: FAILURE

O erro ainda é o mesmo renato:

SonarQube server [localhost:9000] can not be reached

Realmente é muito estranho, você poderia tirar prints de todas as configurações feitas e colocar no Google Drive e compartilhar um link pra eu poder acessar e tentar identificar o problema, a grande questão é que o Jenkins não consegue chegar até o SonarQube. Porém você mesmo informou que o SonarQube Server está em execução no endereço http://localhos:9000. Preciso ver as configurações para entender o porque desse erro!

Fala meu amigo Jonilson, tudo bem !

Não vou descansar até resolver esse problema e consolidar esse conhecimento !

Segue abaixo o link com as imagens.

https://drive.google.com/open?id=1ySK-q9p69cZZALOwIb3zfOFtuczzCpm6

Olhei as imagens, e ficou faltando a configuração de SonarQube servers, você poderia verificar se está corretamente configurado o servidor do SonarQube que realmente está em execução!

Deve fica como na imagem: https://pasteboard.co/J4K7oql.png.

Fala Jonilson, tudo bem meu amigo !

Então eu verifiquei as minha configurações do SonarQube Server, e está tudo igual a imagem que você me enviou. Deixarei aqui a baixo a foto de como está a minha configuração.

https://drive.google.com/open?id=1p0vWHc6HCC3QrMgd-ONtAnAfBIvGjeDU

PS: Desculpe a demora de responder, nesse período de pandemia as coisas estão meias conturbadas, mas estou tentando manter os estudos na medida do possível.

Forte abraço !

É verdade Renato, sua configuração está certinha, assim acho que podemos tentar outra coisa, coloca no campo Server URL o endereço http://127.0.01:9000 e tenta novamente, caso não funcione, verifica qual o endereço da sua máquina na rede local e coloca no Server URL o endereço http://<seu-ip-na-rede-local>:9000 e tenta novamente e fala pra gente o resultado!

Fala meu amigo, tudo bem !

Então, fiz o passo a passo que você me pediu a cima e adivinha, não funcionou :(

Tentei colocar os ip's local 127.0.0.1 / 192.168.0.1 / 192.168.1.9 e nada funcionou. Será que tem alguma outra coisa que eu possa fazer ?

solução!

Realmente é muito estranho isso! Você consegue acessar a interface gráfica do SonarQube usando a URL http://localhost:9000 no navegador? Como na imagem: SonarQube em http://localhost:9000

Se você consegue acessar, então faz o seguinte, pare o SonarQube, e depois exclua a pasta dele no disco C:\ e depois exclua também a pasta .sonar que fica em: C:\Users\Renato\.sonar.

Depois faça novamente o processo de instalação do SonarQube:

Crie uma pasta com o nome sonarqube dentro do disco local "C:" e descompacte o arquivo baixado dentro dessa pasta C:\sonarqube. Agora você deve ir na pasta bin (dentro de C:\sonarqube), e entrar na pasta correspondente ao seu sistema operacional:

  • Entre na pasta windows-x86-32 caso seu sistema seja de 32bits.

  • Ou então entre pasta windows-x86-64 caso seu sistema seja de 64bits.

E por fim execute o arquivo StartSonar.bat. E depois tente realizar o Build novamente.

E fala pra gente o resultado!

JONILSON !!!! funcionou \o/

Porém nem tudo são folhes !!! Ele fez o scanner no sonar, mas ele não fez o deploy no tomcat ! Oque poderá ser ?

PS: como esse tópico já tem bastante tempo, abrirei um novo tópico para deixa o erro que apresentou agora !