# Include jobs from external YAML files

You can include the jobs in this repository's YAML files as follows:

```yml
include:
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/build.yml
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/sonarqube.yml
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/tests.yml
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/deploy.yml
```

You can include the execution order in yout .gitlab-ci.yml file as follows:

```yml
stages:
  - build
  - code_analysis
  - test
  - deploy
```

Additionally the `mvn` program will look for the pom file in the root of the repository, but typically we have all the java
files inside a folder, so we need to tell mvn to look for the pom in that folder, for doing so we have to overwrite the `MAVEN_POM_DIR` variable defined in the [build.yml](build.yml) file. For doing so we have to write the following in ur CI file, specifying the path of th directory in which the `pom.xml` is contained.

```yml
variables:
  MAVEN_POM_DIR: "{FOLDER}"

```

There are also 2 variables that are used in deploy command that can be overrided:
```yml
variables: 
  MAVEN_BUILD_OPTIONAL: ""    # empty by default. Can be used for javadoc:jar, for example
  MAVEN_BUILD_SOURCE: "jar"   # Indicates the generated source type (jar, war ...)
  
```

## Example

An example of a valid .gitlab-ci.yml can be:

```yml
include:
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/build.yml
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/sonarqube.yml
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/tests.yml
  - https://git.code.tecnalia.com/digicon-webxr-store/ci-files/-/raw/master/maven-packages/deploy.yml

variables:
  MAVEN_POM_DIR: "jv_lib_ai_client"

stages:
  - build
  - code_analysis
  - test
  - deploy

```