AWS Lambda deployment - powershell

I'm trying to deploy my lambdas (.NET Core 2.0) into AWS by using AWS CLI + TeamCity + Powershell script. I have some steps , including deploy step and applying new aliase number step.
While deploy step I don't get alias number (lambda version). A script returns me something like "function = ", but it should be like "result = 44 (or any other lambda version)".
Here's a script (mix of Powershell + AWS CLI commands).
FOR ( /F "tokens=* delims=" %%%A IN ('dotnet lambda deploy-function MyLambda --profile default --region my-server-region --configuration Release --function-publish true') DO ( set result=%%%A )){
FOR ( /F "tokens=1,2,3,4,5,6 delims= " %%%A IN ('echo %%%result%%%') DO ( set result=%%%F )){
#echo on
echo %env.MyLambdaVersion%
#echo off
echo "##teamcity[setParameter name='env.MyLambdaVersion' value='%%result%%']"
}
}
I actually don't know what I do wrong, actually this script was written before I started to work on this project. Any advice or any link will be helpfull, thanks :)
EDIT
I expect this kind of respinse, where i can get MyLambda version
Succesfull build scrinshot1: https://i.stack.imgur.com/bOIGr.jpg
But instead of it I'm getting this result.
Invalid response
EDIT 2
Output of the script in text format
Step 17/36: Deploying new version of Lambda "MyLambda" (Command Line) (3m:16s)
[13:27:03][Step 17/36] Starting: C:\BuildAgent\temp\agentTmp\custom_script1964828788270486366.cmd
[13:27:03][Step 17/36] in directory: C:\BuildAgent\work\3f3a1ea85ff2ff09
[13:30:10][Step 17/36]
[13:30:11][Step 17/36] C:\BuildAgent\work\3f3a1ea85ff2ff09\Proj\Lambda\Proj.Lambda.MyLambda>echo
[13:30:12][Step 17/36] ECHO is on.
[13:30:16][Step 17/36] "
[13:30:16][Step 17/36] ##teamcity[setParameter name='env.MyLambdaVersion' value='function: ']
[13:30:16][Step 17/36] "
[13:30:20][Step 17/36] Process exited with code 0

Related

How to Abort Informatica workflow if source file has only header row

I have a requirement wherein I am checking if source file which is in CSV format has only header rows i.e. 1 row only then I need to fail the informatica workflow. Informatica is installed in Windows server so only Command task is supported not Unix or bash.
I am using below code to count lines in source file using Command Task in workflow.
for /f "usebackq" %%b in (type $$outputfile ^| find "" /v /c)do (
echo line count is %%b> $$count_file.txt
)
)
Here $$outfile and $$count_file paths and filenames are picked from param files.
There is an ABORT() function that you can use in expression transformation.
Create a dummy column and put a sorter, aggregator right after the source qualifier. in the aggregator, get a count of all data and then join it back to the main flow. After joiner, put an expression transformation with below condition-
IIF( cnt_all > 1, NULL, ABORT( 'Only header exists in the input file! Session will be aborted.'))
Whole mapping should look like this --
SQ -- EXP(add dummy_col) -->SRT on dummy_col -->AGG on dummy_col, calculate Count(*)->|
|--------------------------------------------> JNR on dummy_col -->EXP (abort if count <=1) --> existing mapping logic...
EDIT :
From command task, you can call pmcmd abortworkflow when your condition satisfies. Normal syntax is below -
pmcmd abortworkflow -service service -user username -password password -f folder workflow

Running java utility via command in azure pipelines does not pass parameters

I have created an utility (java jar-file) to generate a file upon the building process. And placed it into /tools folder in my source code root folder.
In azure-pipelines I am using this approach to run this jar-file upon building the project (Xamarin project).
- task: CmdLine#2
inputs:
script: "java -jar $(build.SourcesDirectory)/tools/version2image.jar $(fullVersionText) $(androidVersionFileLocation)"
The task launched ok, but in the logs I get the following:
2020-08-17T14:48:45.4688112Z java -jar D:\a\1\s/tools/version2image.jar 1.0.0.123 'D:\a\1\s/XamarinProject/XamarinProject.Android/Resources/drawable/version.png'
2020-08-17T14:48:45.5231861Z ========================== Starting Command Output ===========================
2020-08-17T14:48:45.5731945Z ##[command]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\d5706f7c-43cd-4d50-8f17-98a6ae0a3391.cmd""
2020-08-17T14:48:46.8000947Z Version 2 Image Utility. version 1.0
2020-08-17T14:48:46.8001744Z
2020-08-17T14:48:46.8002367Z
2020-08-17T14:48:46.8003059Z Usage:
2020-08-17T14:48:46.8004115Z
2020-08-17T14:48:46.8004468Z java -jar version2image.jar version_string output_file_location
2020-08-17T14:48:46.8004769Z
2020-08-17T14:48:46.8005096Z Example:
2020-08-17T14:48:46.8005464Z
2020-08-17T14:48:46.8005739Z java -jar version2image.jar 1.0.0.121 c:/myproject/images/version.png
2020-08-17T14:48:46.8005961Z
2020-08-17T14:48:46.8507661Z ##[section]Finishing: CmdLine
In other words Azure does not pass parameters properly to the jar file. My application thinks that it launched without parameters.
But when I run this utility locally on my computer it works ok.
If it helps, in the java utility I get command line parameters like that:
final int correctParamsCount = 2;
if (args.length != correctParamsCount) {
System.out.println("Usage:\n\njava -jar version2image.jar <version_string> <output_file_location>\n");
System.out.println("Example:\n\njava -jar version2image.jar 1.0.0.121 c:/myproject/images/version.png\n");
System.exit(0);
}
final String versionNumber = args[0];
final String outputFilePath = args[1];
How can I fix this issue?
To resolve this issue (thanks to #riQQ) I should update AndroidVersionFileLocation variable, and remove single quote symbols from the path.
And add double quotes to the utility command call:
It should look like this:
script: 'java -jar $(build.SourcesDirectory)/tools/version2image.jar "$(fullVersionText)" "$(androidVersionFileLocation)"'
instead of this:
script: "java -jar $(build.SourcesDirectory)/tools/version2image.jar $(fullVersionText) $(androidVersionFileLocation)"

Play framework 2.5 not loading application.prod.conf, only the default application.conf

I've run sbt clean stage and am trying to run my application in prod mode using the generated script. When running target\universal\stage\bin\app-name.bat . -Dconfig.resource=application.prod.conf it complains that the application secret is not set. After some troubleshooting I realised that it was still loading the default config filebecause after deleting target\universal\stage\conf\application.conf I get the following error:
Oops, cannot start the server.
Configuration error: Configuration error[application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties]
I've tried refering to it with the full path using -Dconfig.file, with the same result. How do I get it to load the right config file, other than renaming it to application.conf?
Here is the full command contained in the .bat file, autogenerated by sbt:
#REM game-check-match launcher script
#REM
#REM Environment:
#REM JAVA_HOME - location of a JDK home dir (optional if java on path)
#REM CFG_OPTS - JVM options (optional)
#REM Configuration:
#REM GAME_CHECK_MATCH_config.txt found in the GAME_CHECK_MATCH_HOME.
#setlocal enabledelayedexpansion
#echo off
if "%GAME_CHECK_MATCH_HOME%"=="" set "GAME_CHECK_MATCH_HOME=%~dp0\\.."
set "APP_LIB_DIR=%GAME_CHECK_MATCH_HOME%\lib\"
rem Detect if we were double clicked, although theoretically A user could
rem manually run cmd /c
for %%x in (!cmdcmdline!) do if %%~x==/c set DOUBLECLICKED=1
rem FIRST we load the config file of extra options.
set "CFG_FILE=%GAME_CHECK_MATCH_HOME%\GAME_CHECK_MATCH_config.txt"
set CFG_OPTS=
if exist "%CFG_FILE%" (
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%CFG_FILE%") DO (
set DO_NOT_REUSE_ME=%%i
rem ZOMG (Part #2) WE use !! here to delay the expansion of
rem CFG_OPTS, otherwise it remains "" for this loop.
set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME!
)
)
rem We use the value of the JAVACMD environment variable if defined
set _JAVACMD=%JAVACMD%
if "%_JAVACMD%"=="" (
if not "%JAVA_HOME%"=="" (
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
)
)
if "%_JAVACMD%"=="" set _JAVACMD=java
rem Detect if this java is ok to use.
for /F %%j in ('"%_JAVACMD%" -version 2^>^&1') do (
if %%~j==java set JAVAINSTALLED=1
if %%~j==openjdk set JAVAINSTALLED=1
)
rem BAT has no logical or, so we do it OLD SCHOOL! Oppan Redmond Style
set JAVAOK=true
if not defined JAVAINSTALLED set JAVAOK=false
if "%JAVAOK%"=="false" (
echo.
echo A Java JDK is not installed or can't be found.
if not "%JAVA_HOME%"=="" (
echo JAVA_HOME = "%JAVA_HOME%"
)
echo.
echo Please go to
echo http://www.oracle.com/technetwork/java/javase/downloads/index.html
echo and download a valid Java JDK and install before running game-check-match.
echo.
echo If you think this message is in error, please check
echo your environment variables to see if "java.exe" and "javac.exe" are
echo available via JAVA_HOME or PATH.
echo.
if defined DOUBLECLICKED pause
exit /B 1
)
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
set _JAVA_OPTS=%JAVA_OPTS%
if "!_JAVA_OPTS!"=="" set _JAVA_OPTS=!CFG_OPTS!
rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments
rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPTS
set _JAVA_PARAMS=
set _APP_ARGS=
:param_loop
call set _PARAM1=%%1
set "_TEST_PARAM=%~1"
if ["!_PARAM1!"]==[""] goto param_afterloop
rem ignore arguments that do not start with '-'
if "%_TEST_PARAM:~0,1%"=="-" goto param_java_check
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
shift
goto param_loop
:param_java_check
if "!_TEST_PARAM:~0,2!"=="-J" (
rem strip -J prefix
set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2!
shift
goto param_loop
)
if "!_TEST_PARAM:~0,2!"=="-D" (
rem test if this was double-quoted property "-Dprop=42"
for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
if not ["%%H"] == [""] (
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
) else if [%2] neq [] (
rem it was a normal property: -Dprop=42 or -Drop="42"
call set _PARAM1=%%1=%%2
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
shift
)
)
) else (
if "!_TEST_PARAM!"=="-main" (
call set CUSTOM_MAIN_CLASS=%%2
shift
) else (
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
)
)
shift
goto param_loop
:param_afterloop
set _JAVA_OPTS=!_JAVA_OPTS! !_JAVA_PARAMS!
:run
set "APP_CLASSPATH="
set "APP_MAIN_CLASS=-jar %APP_LIB_DIR%\game-check-match.game-check-match-0.1.0-launcher.jar"
if defined CUSTOM_MAIN_CLASS (
set MAIN_CLASS=!CUSTOM_MAIN_CLASS!
) else (
set MAIN_CLASS=!APP_MAIN_CLASS!
)
rem Call the application and pass all arguments unchanged.
"%_JAVACMD%" !_JAVA_OPTS! !GAME_CHECK_MATCH_OPTS! -cp "%APP_CLASSPATH%" %MAIN_CLASS% !_APP_ARGS!
#endlocal
:end
exit /B %ERRORLEVEL%

Add a perl project in Komodo

I have an old perl(5.12.3) project, which I would like to debug in the komodo 3.0.1 environment (temporarely i have only this old version). The project is a multiple module project, with a three like structure:
Root
core
module1.pm
...
external
ext_module.pm
...
caller.bat
The project start point is the .bat file. Would it be possible to add and debug it in komodo? Any suggestion are appreciated.
set PERL_EXIST=0
perl -version >nul 2>&1 && ( set PERL_EXIST=1 )
if %PERL_EXIST% EQU 0 (
rem if perl doesn't exist give an error message and finish
echo.
echo ERROR: Perl %PERL_DIR% is missing
set PERL_EXIST=
set MY_EXIT_CODE=1
goto EXIT
)
.
.
.
#perl starts here
use core::FirstModule;
use Cwd qw(getcwd chdir);
use Switch;
use core::FirstModule;
use Env qw(PATH VAR_1 PROJ_VERSION CORE_LOC );
# adapt the environment to point to main folder
$ENV{'CORE_LOC'}=~s/[\\\/]?[^\\\/]*$//;
if ($ENV{'CORE_LOC'}=~/[\\\/].*$/i) {
$ENV{'CORE_LOC'} =~s/[\\\/]?[^\\\/]*$//;
.
.
.
.
push #INC,$sourceDir;
$hFirstModule = core::FirstModule->new("object properties");
$hFirstModule->checkDir($dir_version);

Running PowerShell from MSdeploy runcommand does not exit

Im am trying to get MSDeploy to execute a PowerShell script on a remote server. This is how i execute MSDeploy:
msdeploy \
-verb:sync \
-source:runCommand='C:\temp\HelloWorld.bat', \
waitInterval=15000,waitAttempts=1 \
-dest:auto,computername=$WebDeployService$Credentials -verbose
HelloWorld.bat contains:
echo "Hello world!"
powershell.exe C:\temp\WebDeploy\Package\HelloWorld.ps1
echo "Done"
The HelloWorld.ps1 only contains:
Write-Host "Hello world from PowerShell!"
However, it seems like PowerShell never terminates. This is the output from running the msdeploy:
Verbose: Performing synchronization pass #1.
Verbose: Source runCommand (C:\temp\HelloWorld.bat) does not match destination (C:\temp\HelloWorld.bat) differing in attributes (isSource['True','False']). Update pending.
Info: Updating runCommand (C:\temp\HelloWorld.bat).
Info:
Info: C:\temp>echo "Hello world!"
"Hello world!"
C:\temp\WebDeploy>powershell.exe C:\temp\HelloWorld.ps1
Info: Hello world from Powershell!
Info:
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Users\peter\AppData\Local\Temp\gaskgh55.b2q.bat
"') is still running. Waiting for 15000 ms (attempt 1 of 1).
Error: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Users\peter\AppData\Local\Temp\gaskgh55.b2q.bat"'
) was terminated because it exceeded the wait time.
Error count: 1.
Anyone knows a solution?
Your scenario and problem look similar to this reported issue:
PowerShell.exe can hang if STDIN is redirected
If this is the case then try this workaround: use -inputformat none:
powershell.exe -inputformat none C:\temp\WebDeploy\Package\HelloWorld.ps1
I have tried this with "a fake msdeploy" program that calls the .bat file like this:
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "cmd.exe";
si.Arguments = "/c " + args[0];
si.RedirectStandardInput = true;
si.UseShellExecute = false;
var process = Process.Start(si);
process.WaitForExit();
}
}
This demo does have the same problem that you describe and the workaround helps. If msdeploy calls the .bat file in the same or similar way then hopefully this is a solution.
powershell.exe -file ScriptFile.ps < CON
This solve the problem without resorting to undocumented features.