|
|
_Life is complex, and so can be Continuous Integration pipelines_ 🥰
|
|
|
|
|
|
In order to fetch code from other gitlab.esa.int repos from another project CI pipeline, you need to provide git credentials (i.e. username & password) with enough privileges to access that repository.
|
|
|
In order to fetch code from other gitlab.esa.int repos from another project CI pipeline, you need to provide git credentials (i.e. username & password) with enough privileges to access that repository.
|
|
|
|
|
|
From a Gitlab perspective, those credentials are the same ones the Gitlab runner is using to fetch the project you are running. They will have the same permissions as the user triggering the CI/CD pipeline.
|
|
|
|
|
|
|
|
|
## Regular Gitlab CI
|
|
|
|
|
|
Just add this code before your `script` block.
|
|
|
|
|
|
```
|
|
|
```plaintext
|
|
|
before_script:
|
|
|
...
|
|
|
- git config --global credential.https://gitlab.esa.int.username $CI_REGISTRY_USER
|
... | ... | @@ -23,21 +22,24 @@ script: |
|
|
...
|
|
|
```
|
|
|
|
|
|
You also need to allow the project to be fetched with the CI_JOB_TOKEN pipeline.
|
|
|
|
|
|
In _Settings\>CI/CD\>Token Access\> Limit access to this project_, add your project.
|
|
|
|
|
|
## Fetching the repo from a Docker container build
|
|
|
|
|
|
In .gitlab-ci.yml (your actual tags in Docker might vary, the relevant part are the args)
|
|
|
|
|
|
```
|
|
|
```plaintext
|
|
|
script:
|
|
|
...
|
|
|
- docker build -t $CI_REGISTRY_IMAGE:latest --build-arg GIT_USER=gitlab-ci-token --build-arg GIT_PASS=$CI_BUILD_TOKEN .
|
|
|
...
|
|
|
|
|
|
```
|
|
|
|
|
|
In the Dockerfile
|
|
|
```
|
|
|
|
|
|
```plaintext
|
|
|
...
|
|
|
ARG GIT_USER
|
|
|
ARG GIT_PASS
|
... | ... | @@ -49,6 +51,4 @@ RUN chmod +x /git_env_password.sh |
|
|
RUN git clone https://gitlab.esa.int/YOUR_OTHER_PROJECT
|
|
|
...
|
|
|
RUN rm /git_env_password.sh # although this is not strictly necessary
|
|
|
```
|
|
|
|
|
|
|
|
|
``` |
|
|
\ No newline at end of file |