Trying to run sonar-runner from shell script - sonar-runner

I want to run sonar runner every night via a cronjob though nothing happens when I run this script:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cd path_to_repo
git checkout master
echo "on master"
git pull
echo "pulled"
touch text.txt
sonar-runner
echo "finished scan"
When I run the command sonar-runner in the same folder it works fine.
Also I added a test command touch which also works. Only sonar-runner does not work.

So stupid. In the script I set the path, though I set it without the path to sonarqube...
The script works like this:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/var/www/sonarcube/sonarrunner/bin
cd path_to_file
git checkout master
echo "on master"
git pull
echo "pulled"
cd ../..
echo "back to root folder"
sonar-runner
echo "finished scan"

Related

run serve -s build from .bat file

I want to execute serve -s build from .bat file as admin, this is my .bat file:
#ECHO OFF
cd "C:\Users\user\Desktop\Brabender\build-20220517T114506Z-001"
serve -s build
It works if I manually run it as admin, but I need it to run from Windows Startup Folder everytime the system starts, any ideas how to do it as admin automatically?
Some minor changes to your batch file, adding /d to the cd command
#echo off
cd /d "C:\Users\user\Desktop\Brabender\build-20220517T114506Z-001"
serve -s build
Assuming we call the file something like serve-build-script.bat, run from cmd.exe
schtasks /create /tn "Serve-Build" /tr "c:\<Path-to-Batch-file>\batchfile-name.bat" /sc onstart /ru "user" /rp "password" /np /f
The correct version updated as per confirmation from the chat.

how capture GRADLE gradlew assembleDebug exit code in bash script

i have a simple batch script for GRADLE android as below
#ECHO ON
set DIR=path
set APP=%DIR%\app1
cd %APP%
./gradlew assembleDebug
next i want to check when Gradlew build is done, i can continue next command
something like
if(./gradlew assembleDebug) then echo "pass"
else echo "failed"
but i don't know how to implement in batch script
anyone know please tell me how to implement
thanks

not able to set environment variable using Jenkins batch command line

I am working on Jenkins android app automation. I have automated Android version name from manifest file for example version name 1.0.1.45 and set the version name as environment variable. I have test.bat file code looks like below.
#For /F %%A In ('Powershell -C "[xml]$fC=Get-Content 'AndroidManifest.xml';"^
"$fC.manifest.versionName"') Do #Set "versionName=%%A"
#Echo %versionName% > name.txt
Now I am calling this test.bat file from Jenkins under "execute windows batch command" section and it ran but it is not able to set as environment variable.
Also I am giving svn command under "execute windows batch command" as
svn commit -m " updated version %versionName% ".
In build output it should show update version 1.0.1.25. but is not taking as a environment variable. Please can you help me

Can I run git shell and execute command from cmd?

I would like to write a bat script that runs simultaneously Unity, visual studio and git shell. I would like to make git shell change directory (it always start at default github's repositories location), but I can't figure how.
so far, I've got something like that:
echo off
d:
cd D:\<path>\Visual Studio\Common7\IDE
start .\devenv.exe "C:\<path>\solution.sln"
cd D:\<path>\Unity\Editor
start .\Unity.exe -projectPath "C:\<path>\project directory"
c:
cd C:\Users\<username>\AppData\Local\GitHub\
start .\GitHub.appref-ms --open-shell //and now i need to execute "cd ../my project" on it

Have .bat file continue after it runs a command

I need to figure out this seemingly very simple issue on windows .bat file. I have been using Linux for past 10 years full-time, so I am in pretty unfamiliar territory when it comes to .bat scripts.
We have some units tests that need to run on from this .bat file, and a build needs to be generated after the tests have run.
The bat file itself is very simple, I was thinking of just chaining the commands:
cls
echo "Running test suite - CRMSync"
echo
echo
REM from command: --static-backup
phpunit --bootstrap test/bootstrap_test.php --verbose --log-junit
echo "Running phploc for CRMSync"
phploc --count-tests --verbose > C:\CRMsync\testResults\phploc\index.html
echo "Executing phing"
phing
Now, simple enough except nothing is executed past phpunit command. How do I deal with this?
The unit tests run fine, but I am suspecting it could even be in the unit test lib that process is killed. Is there a way to fork the process somehow or get the other commands below to run?
Thanks SO'ers, as always, any help greatly appreciated.
I had the same problem for a development script that I made. And I tried all given solutions without being successful. At the end, I did it with cmd /C.
From the windows docs it will:
Run Command and then terminate
So for example, you can use it as follows:
cls
echo "Running test suite - CRMSync"
echo
echo
REM from command: --static-backup
cmd /C phpunit --bootstrap test/bootstrap_test.php --verbose --log-junit
echo "Running phploc for CRMSync"
cmd /C phploc --count-tests --verbose > C:\CRMsync\testResults\phploc\index.html
echo "Executing phing"
cmd /C phing
I hope you find this useful.
Similar to the post ujifgc, I use "start /b ..." in these situations. If you encapsulate the call to phpunit in another batch file, you can use "call".
Is phpunit itself a batch file (I don't do much PHP, so am not familiar with the tool)? If so, try using:
call phpunit --bootstrap test/bootstrap_test.php --verbose --log-junit
Try start /WAIT phpunit ... to fork process and wait for it or just start phpunit ... to fork and continue. Help is here: start /?
I used
start /b code .
cmd /k ng serve --build-optimizer --aot
to start Visual Studio Code and then a node js server.
But the Command line glitched with the % update text and more.
I then used
cmd /C code .
cmd /k ng serve --build-optimizer --aot
and the glitching stopped for the server progress update.

Resources