Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0db35cf3 authored by Thierry Martinez's avatar Thierry Martinez
Browse files

Fix README.md

parent 4914215e
Branches main
No related tags found
No related merge requests found
Pipeline #763818 passed
......@@ -436,14 +436,69 @@ stages:
Every job that will use the Terraform configuration file needs to copy
the file referred by `SSH_PRIVATE_KEY` into the file `id_rsa`.
To copy the file without overriding all the script,
we use the `before_script` key:
defining the `before_script` key at top-level, outside any job,
makes the file be copied before every job.
To copy the file without overriding the script inherited from the
Terraform template, we use the `before_script` key:
we define a template job `.with-rsa-key`, which every job requiring
the `id_rsa` file will extend
(if there were no `execute` jobs, we could also have defined the
`before_script` key at top-level, outside any job,
making the file be copied before every job).
```yaml
before_script:
- cp $SSH_PRIVATE_KEY id_rsa
.with-rsa-key:
before_script:
- cp $SSH_PRIVATE_KEY id_rsa
```
By default, the `deploy` job is defined as manual in the template.
To execute it automatically, we redefine the `rules:` key as empty.
```yaml
deploy:
tags:
- linux
- small
extends:
- .terraform:deploy
- .with-rsa-key
dependencies:
- build
rules:
```
In the `execute` stage, we compile `hello_world.c` with `gcc`
on Ubuntu, `cl` (Microsoft Visual Studio) on Windows,
and `clang` on Mac OS X.
On Windows, we need to run `vcvars64.bat` to get the
environment initialized for Visual Studio.
This batch file requires CMD shell, whereas `gitlab-runner`
deprecates CMD in favor of PowerShell (see
[documentation](https://docs.gitlab.com/runner/shells/)).
The documentation gives the following
[trick](https://gitlab.com/guided-explorations/microsoft/windows/call-cmd-from-powershell/-/blob/master/.gitlab-ci.yml) to execute batch files with CMD from PowerShell:
write the script in a file and run `CMD.EXE /C` on it.
```yaml
execute windows:
stage: execute
image: alpine
tags:
- terraform
- windows
script:
# The trick for running cmd scripts from powershell runner is documented
# here:
# https://gitlab.com/guided-explorations/microsoft/windows/call-cmd-from-powershell/-/blob/master/.gitlab-ci.yml
- |
set-content $env:public\inline.cmd -Value @'
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
cl /Fe:hello_world.exe hello_world.c
'@
CMD.EXE /C $env:public\inline.cmd
exit $LASTEXITCODE
artifacts:
paths:
- hello_world.exe
```
## Ignored files in [`.gitignore`](.gitignore)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment