# Use import in .travis.yml does not trigger build

**URL:** https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658
**Category:** Early Releases
**Tags:** travis-yml-syntax
**Created:** [March 20, 2020, 12:14pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658 "2020-03-20T12:14:28Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![ron190](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ron190/32/3488_2.png) [@ron190](https://travis-ci.community/u/ron190)
#### Post date: [March 20, 2020, 12:14pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/1 "2020-03-20T12:14:28Z")

</div>

Hi, I have a fairly big .travis.yml that I want to separate in different files, specificaly the `before_install` parts.

I found the new functionality of `import` syntax that I thought corresponds to this use case, though I do not manage to use it, the build is not triggered after my push.

I have activated `Build Config Validation` feature and tested also with `version: ~> 1.0`.

> <https://github.com/ron190/jsql-injection/commit/fab59bf0eff6a326f32ab2e62edd2a69a6dada11?diff=split>

I thought I could write like this, do you think there’s mistake in my code or in my understanding?

```
before_install:
 
import: 
  - ./src/test/resources/docker/build.yml
  - ./src/test/resources/docker/run.yml
  - ./src/test/resources/docker/config.yml

script: mvn clean verify sonar:sonar
  
import: ./src/test/resources/docker/metrics.yml

```

Thanks

---

<div class="post-metadata">

### Author: ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)
#### Post date: [March 20, 2020, 12:19pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/2 "2020-03-20T12:19:42Z")

</div>

Is it intended that you have two `import` keys?

---

<div class="post-metadata">

### Author: ![ron190](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ron190/32/3488_2.png) [@ron190](https://travis-ci.community/u/ron190)
#### Post date: [March 20, 2020, 12:29pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/3 "2020-03-20T12:29:52Z")

</div>

Yes, I would want to import 3 docker relative parts into `before_install` and one docker relative part into `script`, respectively `build`, `run`, `config`, then `metrics`.

The working single .yml file is like this

```
before_install:
  
  - export MAVEN_OPTS="-Xms512m -Xmx3g -XX:PermSize=256m $MAVEN_OPTS"
    
  # Docker configuration
  - docker build -t mysql 
    -f src/test/resources/docker/Dockerfile.mysql .
    
  - docker build -t mysql 
    -f src/test/resources/docker/Dockerfile.mysql-5.5.40 .
    
  - docker build -t postgres 
    -f src/test/resources/docker/Dockerfile.postgres .
    
  - docker build -t sqlserver 
    -f src/test/resources/docker/Dockerfile.sqlserver .
    
  - docker run --name jsql-mysql  
    --publish 3306:3306 
    -e MYSQL_ROOT_PASSWORD=my-secret-pw 
    -d mysql
    
  - docker run --name jsql-mysql-5.5.40 
    --publish 3307:3306 
    -e MYSQL_ROOT_PASSWORD=my-secret-pw 
    -d mysql:5.5.40
    
  - docker run --name jsql-postgres 
    --publish 5432:5432 
    -e POSTGRES_PASSWORD=my-secret-pw 
    -d postgres 
    -c 'shared_buffers=256MB'
    -c 'max_connections=1000'
    
  - docker run --name jsql-sqlserver 
    --publish 1434:1434 
    --publish 1433:1433 
    -e "ACCEPT_EULA=Y" 
    -e "SA_PASSWORD=yourStrong(!)Password"
    -u 0:0
    -d sqlserver 
    
  - docker images && docker ps && pwd
  
  # Buff MySQL
  - docker exec -it jsql-mysql /bin/bash
    -c "
       mysql -uroot -pmy-secret-pw -e '
       SET GLOBAL max_connections = 100000;
       SET GLOBAL thread_cache_size = 16384;
       SET GLOBAL table_open_cache = 524288;
       ';
       "

  # Check MySQL status
  - docker exec -it jsql-mysql /bin/bash
    -c "
       mysql -uroot -pmy-secret-pw -e '
       SHOW GLOBAL variables WHERE Variable_name RLIKE \"thread_cache_size|^max_connections|table_open_cache\";
       SHOW GLOBAL status WHERE Variable_name RLIKE \"Threads_cached|Max_used_connections|Threads_created|Connections|Opened_tables|Threads_connected|Threads_running|^Queries\"
       ';
       "

  # Check Postgres status
  - docker exec -it jsql-postgres /bin/bash
    -c "
       export PGPASSWORD=my-secret-pw;
       psql -U postgres -h 127.0.0.1 -d \"\" -e -a -c '
       show max_connections;
       ';
       "
       
  - sleep 10s
  - sudo docker exec -it jsql-sqlserver /opt/mssql-tools/bin/sqlcmd -S "tcp:127.0.0.1,1434" -U SA -P "yourStrong(!)Password" -Q "select @@version"

script:

  - mvn clean verify sonar:sonar
  
  # Check MySQL status
  - docker exec -it jsql-mysql /bin/bash
    -c "
       mysql -uroot -pmy-secret-pw -e '
       SHOW GLOBAL status WHERE Variable_name RLIKE \"Threads_cached|Max_used_connections|Threads_created|Connections|Opened_tables|Threads_connected|Threads_running|^Queries\"
       ';
       "
```

---

<div class="post-metadata">

### Author: ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)
#### Post date: [March 20, 2020, 3:51pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/4 "2020-03-20T15:51:12Z")

</div>

It’s not entirely clear to me why, but [https://travis-ci.org/github/ron190/jsql-injection/requests](https://travis-ci.org/github/ron190/jsql-injection/requests) shows that we were unable to import `metrics.yml`.

---

<div class="post-metadata">

### Author: ![ron190](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ron190/32/3488_2.png) [@ron190](https://travis-ci.community/u/ron190)
#### Post date: [March 20, 2020, 4:33pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/5 "2020-03-20T16:33:21Z")

</div>

Ok, I didn’t know the Requests panel, I see the error now 😄, but I can’t figure out what’s different in file `metrics.yml` than it is in the three other ones.

---

<div class="post-metadata">

### Author: ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)
#### Post date: [March 20, 2020, 7:14pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/6 "2020-03-20T19:14:47Z")

</div>

I’d start with combining the two `import` keys. It’s definitely unnatural.

---

<div class="post-metadata">

### Author: ![ron190](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ron190/32/3488_2.png) [@ron190](https://travis-ci.community/u/ron190)
#### Post date: [March 20, 2020, 7:42pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/7 "2020-03-20T19:42:01Z")

</div>

I replaced completely the 2nd import with a .sh, because I have to check dockerized databases metrics after integration tests.

```
before_install:
  - export MAVEN_OPTS="-Xms512m -Xmx3g -XX:PermSize=256m $MAVEN_OPTS"
  
import: 
  - src/test/resources/docker/build.yml
  - src/test/resources/docker/run.yml
  - src/test/resources/docker/config.yml

script:
  - mvn clean verify sonar:
  - ./src/test/resources/docker/metrics.sh

```

Now strangely enough it fails on previous single import bloc with error:

```
Could not parse ron190/jsql-injection:src/test/resources/docker/build.yml@766935975b8df2e6
```

---

<div class="post-metadata">

### Author: ![ron190](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ron190/32/3488_2.png) [@ron190](https://travis-ci.community/u/ron190)
#### Post date: [March 20, 2020, 7:53pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/8 "2020-03-20T19:53:36Z")

</div>

Then I tried to just use `.sh` with Git executable rights and it works, but parsing in `.yml` is cleaner without the sh horrible syntax:

```
before_install:     
  - ./src/test/resources/docker/build.sh
  - ./src/test/resources/docker/run.sh
  - ./src/test/resources/docker/config.sh

script:
  - mvn clean verify sonar:
  - ./src/test/resources/docker/metrics.sh

```

With awful .sh :

```
REM Buff MySQL
docker exec -it jsql-mysql /bin/bash\
-c "\
   mysql -uroot -pmy-secret-pw -e '\
   SET GLOBAL max_connections = 100000;\
   SET GLOBAL thread_cache_size = 16384;\
   SET GLOBAL table_open_cache = 524288;\
   ';\
   "
```

---

<div class="post-metadata">

### Author: ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)
#### Post date: [March 20, 2020, 8:30pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/9 "2020-03-20T20:30:47Z")

</div>

I’m thinking… the structure of your previous YAML files are wrong (it was a simple array); it was a fragment, whereas we expect to find complete YAML file that confirm to our specifications and perform merges and what not to construct the configuration.

---

<div class="post-metadata">

### Author: ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)
#### Post date: [March 20, 2020, 8:48pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/10 "2020-03-20T20:48:05Z")

</div>

> **[Travis CI Documentation](https://docs.travis-ci.com/user/build-config-imports)**
>
> Importing Shared Build Configuration

---

<div class="post-metadata">

### Author: ![ron190](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ron190/32/3488_2.png) [@ron190](https://travis-ci.community/u/ron190)
#### Post date: [March 20, 2020, 8:52pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/11 "2020-03-20T20:52:42Z")

</div>

Yes, I guess now the purpose of `import` is to include nearly complete valid .yml definition rather than just a fragment.

Even if we see some mixed example, taken from the blog post:

> **[Blog – Travis-CI](https://www.travis-ci.com/blog/)**
>
> Get the latest news on CI/CD and find what is happening with Travis CI.

Like :  
[https://github.com/ljharb/es-abstract/blob/master/.travis.yml](https://github.com/ljharb/es-abstract/blob/master/.travis.yml)  
Or:

> <https://github.com/ljharb/travis-ci/blob/master/node/coverage.yml>

I was figuring that YAML was a fairly simple string tree, but I’m missing some notions described in the documentation to understand completely what’s happening:

> sections (keys) that hold maps (hashes), and concatenates sequences (arrays)

Thank you anyway for your support 👍

---

<div class="post-metadata">

### Author: ![bengao01](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@bengao01](https://travis-ci.community/u/bengao01)
#### Post date: [July 22, 2020, 5:56pm UTC](https://travis-ci.community/t/use-import-in-travis-yml-does-not-trigger-build/7658/12 "2020-07-22T17:56:35Z")

</div>

Did you end up resolving this issue, because I ran into something similar. In my main repo’s yml, I’m trying to import a yml from a submodule, but when I commit to my main repo, a build doesn’t trigger. In the requests tab, it shows the request was received and build created successfully, but no build is actually created. In the main repo’s yml, if I don’t specify version: ~\> 1.0, then a build is successfully created but the import command has no effect. If I do specify version to enable the beta feature, no build is created.
