Created
May 6, 2019 19:13
-
-
Save esauser/d8e937568e93dce902b0984abcab8690 to your computer and use it in GitHub Desktop.
Concourse Windows Worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
nuget restore -Verbosity normal | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
msbuild -p:Configuration=Release ^ | |
-p:WarningLevel=0 | |
if %errorlevel% neq 0 exit /b %errorlevel% | |
dotnet.exe test TestProject.csproj --configuration Release --no-build -v n | |
if %errorlevel% neq 0 exit /b %errorlevel% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: build | |
config: | |
platform: windows | |
inputs: | |
- name: input | |
outputs: | |
- name: output | |
run: | |
path: runDockerImage.bat | |
params: | |
DOCKER_IMAGE: mcr.microsoft.com/dotnet/framework/sdk:4.7.2 | |
WORKING_DIRECTORY: input | |
SCRIPT_PATH: build.bat | |
ENV_ENVIRONMENT_VARIABLE: 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set DOCKER_IMAGE 1>NUL 2>NUL | |
if errorlevel 1 echo DOCKER_IMAGE environment variable must be set && exit /b 1 | |
set SCRIPT_PATH 1>NUL 2>NUL | |
if errorlevel 1 echo SCRIPT_PATH environment variable must be set && exit /b 1 | |
for /f "tokens=*" %%G in ('dir /b') do call set volumes=%%volumes%% -v "%cd%\%%G:C:\Concourse\%%G" | |
if errorlevel 1 exit /b %errorlevel% | |
echo. 2>environmentVariables.txt | |
if errorlevel 1 exit /b %errorlevel% | |
for /f "tokens=*" %%G in ('set ^| findstr ENV_') do echo %%G >> environmentVariables.txt | |
if errorlevel 1 exit /b %errorlevel% | |
powershell -Command "(gc environmentVariables.txt) -replace 'ENV_', '' | Out-File environmentVariables.txt -Encoding ascii" | |
if errorlevel 1 exit /b %errorlevel% | |
set WORKING_DIRECTORY 1>NUL 2>NUL | |
if errorlevel 1 (set workingDirectory=Concourse && cmd /c "exit /b 0") else (set workingDirectory=Concourse\%WORKING_DIRECTORY%) | |
if errorlevel 1 exit /b %errorlevel% | |
docker pull %DOCKER_IMAGE% | |
if errorlevel 1 exit /b %errorlevel% | |
docker run ^ | |
--entrypoint "%SCRIPT_PATH%" ^ | |
-w "C:\%workingDirectory%" ^ | |
%volumes% ^ | |
--env-file environmentVariables.txt ^ | |
--rm ^ | |
%DOCKER_IMAGE% | |
if errorlevel 1 exit /b %errorlevel% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just some correction I would suggest:
While setting environment variables, set like
for /f "tokens=*" %%G in ('set ^| findstr ENV_') do echo %%G>> environmentVariables.txt
Instead of
for /f "tokens=*" %%G in ('set ^| findstr ENV_') do echo %%G >> environmentVariables.txt
Note the space before
>>
So that, all environment variable' values don't have a space at the end of them.