Service message in TeamCity not work - service

Command line
echo ##teamcity[setParameter name='test' value='0.%build.number%']
echo %test%
Log
[Step 1/1] ##teamcity[setParameter name='test' value='0.10']
[Step 1/1] 0
What is wrong?

All parameter references resolved before executing script, so if test has value 0 before writing script into file, script content would be
echo ##teamcity[setParameter name='test' value='0.10']
echo 0
Proper solution would be store 0.%build.number% in some variable and use it, e.g.
_test="0.%build.number%"
echo "##teamcity[setParameter name='test' value='0.$_test']"
echo $_test

Related

How to redirect console output of ncftpget to log?

I would like to capture the progress information during downloads.
I have tried, for example from a cmd prompt:
c:\Windows\ncftpget ftp://speedtest.tele2.net/1MB.zip > mylog
c:\Windows\ncftpget ftp://speedtest.tele2.net/1MB.zip >> mylog
c:\Windows\ncftpget ftp://speedtest.tele2.net/1MB.zip > mylog 2>&1
Mylog is always written with 0 bytes, unless the file to be downloaded is already present. In that case I get a 92 byte error message.
The problem seems specific to ncftpget. It works with Windows 10 ftp.
You need to use -d /path/to/log.txt
ncftpget -d /tmp/ncftpget.log <url>
Example output:
2018-12-01 03:49:33 Cmd: USER anonymous
2018-12-01 03:49:33 331: Password required for anonymous
2018-12-01 03:49:33 Cmd: PASS NcFTP#
2018-12-01 03:49:35 530: Login incorrect
2018-12-01 03:49:35 Cmd: QUIT
2018-12-01 03:49:35 221: Goodbye

Jenkins Build successful even after PS script failed to execute

I am executing Jenkins Job which Builds my .csproj file and execute few PS scripts.
Issue is I get a successful email even if my PS script fails,How should I tell my Jenkins Job to trigger me an email also if PS script is failing.
Error Logs-
Copy-Item : The process cannot access the file
'\\10.0.1.190\d$\Build\RPC\abcde.RPC.AirSearch\Common.Logging.Core.dll' because it is being used by another process.
At C:\Users\Administrator\AppData\Local\Temp\hudson9059014122834846757.ps1:3 char:1
+ Copy-Item "C:\AirSearchBnd\src\abcde.Air.Search.RPC.Host\bin\Release\*" "\\$en ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
[AirSearchBnd] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\ADMINI~1\AppData\Local\Temp\hudson9149103993066004448.ps1'"
[SC] CreateService SUCCESS
SERVICE_NAME: AirSearchWindowsService
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 13784
FLAGS :
> C:\Program Files (x86)\Git\bin\git.exe tag -l RPCBUILD_6 # timeout=10
> C:\Program Files (x86)\Git\bin\git.exe tag -a -f -m Jenkins Git plugin tagging with RPCBUILD_6 RPCBUILD_6 # timeout=10
Pushing tag RPCBUILD_6 to repo Dev
> C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files (x86)\Git\bin\git.exe push https://github.com/abcdeHoldings/abcde.Services.Air.Search.git RPCBUILD_6
Email was triggered for: Always
Sending email for trigger: Always
Request made to compress build log
Sending email to: abcde#software.com abcde#software.com abcde#software.com abcde#software.com
Finished: SUCCESS
The easiest way is to configure Jenkins to send e-mails on failed builds and in the Powershell step add the following at the end:
if ($error) { exit 1 }
The problem with Jenkins Powershell plugin is that it doesn't honor the errors that happen in Powershell, only the exit code of the shell itself, this will force build to fail and trigger the email.
There is an option of "Attaching Build Log". You can read the build log to see, if the ps script has failed.

PowerShell IoT-Core only loads .NET modules in interactive mode? How to load explicitly?

The following windows shellscript.cmd works fine from the Windows 10 IoT-Core command line:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nop -c "iex(New-Object Net.WebClient).DownloadString('http://container.blob.core.windows.net/api/myps1.ps1')"
However, when I start it using the IoT-ProcessLauncher from C#, the Net.WebClient is not found after a pause of about 10 seconds (error below). What do I need to add to my shellscript.cmd script to explicitly set up the proper environment for powershell? I tried loading the assembly explicitly with [System.Reflection.Assembly]::LoadWithPartialName('Net.WebClient'); at the beginning of the PS command script but still getting errors. Syntax?
******************** START Argument Information ********************
Args' Count: 1
#0: -nop -c iex(New-Object Net.WebClient).DownloadString('http://container.blob.core.windows.net/api/myps1.ps1')
******************** END Argument Information ********************
.................... START Result Output ....................
Results Count: 0
.................... END Result Output ....................
.................... START Error Output ....................
Errors Count: 1
#0:
- FullyQualifiedId: TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
- ExceptionName: System.Management.Automation.PSArgumentException
- InnerExName: null
- Error Message: Cannot find type [Net.WebClient]: verify that the assembly containing this type is loaded.
- StackTrace: Check .\App_path\Stacktrace.txt for more information
System.UnauthorizedAccessException (Check .\log.txt for more information):
Access to the path 'C:\windows\System32\WindowsPowerShell\v1.0\Stacktrace.txt' is denied.

Creating linked_dirs in Capistrano 3 fails

I am attempting to set up Capistrano with a SilverStripe build and am running into a few troubles setting up the shared directories.
I set the linked_dirs in deploy.rb with the following:
set :linked_dirs, %w{assets vendor}
Since adding this line I get the following error:
[617afa7f] Command: /usr/bin/env mkdir -p /var/www/website/releases/20160215083713 /var/www/website/releases/20160215083713
INFO [617afa7f] Finished in 0.250 seconds with exit status 0 (successful).
DEBUG [88c3de20] Running /usr/bin/env [ -L /var/www/website/releases/20160215083713/assets ] as capistrano#128.199.231.152
DEBUG [88c3de20] Command: [ -L /var/www/website/releases/20160215083713/assets ]
DEBUG [88c3de20] Finished in 0.258 seconds with exit status 1 (failed).
DEBUG [3d61c1c4] Running /usr/bin/env [ -d /var/www/website/releases/20160215083713/assets ] as capistrano#128.199.231.152
DEBUG [3d61c1c4] Command: [ -d /var/www/website/releases/20160215083713/assets ]
DEBUG [3d61c1c4] Finished in 0.254 seconds with exit status 1 (failed).
INFO [3016a8cd] Running /usr/bin/env ln -s /var/www/website/shared/assets /var/www/website/releases/20160215083713/assets as capistrano#128.199.231.152
I am a mega noob when it comes to Capistrano and a semi noob when it comes to server configuration and permissions, so any pointers would be appreciated.
It probably hasn't actually failed. One thing to know about Capistrano is that (success) and (failed) are actually returning the result of the exit status, (success) if 0 and (failed) if non-0.
If we look at the command in question, it says that /usr/bin/env [ -L /var/www/website/releases/20160215083713/assets ] failed. This command is saying "return 0 if /var/www/website/releases/20160215083713/assets exists and is a link (-L). This fails, but that just means it returns non-0, thus the link needs to be created. Note that the next command also fails (-d) with asserting that the path is a directory. And the last line in your output is actually creating the link in question.
You can see the test in the Capistrano codebase here: https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/deploy.rake#L128
You can clean up and simplify the output with https://github.com/mattbrictson/airbrussh. This is developed by one of the primary Capistrano devs.
As a sidenote, similarly all the green text in your terminal is stdout and the red text is stderr. This can also be confusing.

error on Teamcity running command line custom script

I'm trying to run command line -custom script on Teamcity and getting this error (127):
[02:22:25][Step 1/1] /mnt/teamcity/temp/agentTmp/custom_script8657691082445726475: 1: /mnt/teamcity/temp/agentTmp/custom_script8657691082445726475: ./run.sh: not found
[02:22:25][Step 1/1] Process exited with code 127
[02:22:26][Step 1/1] Step run protractor test (Command Line) failed
any ideas?
It looks like some dependency of your script is not found where it expects it:
./run.sh: not found
Is that the actual script you are running? or is your script trying to call that script?
what solved it was adding 'Agent Requirements' (under build Configuration Settings) saying that 'system.agent.name' equals to the name of the Agent we use.