Create specifc folder from Gitlab CI artifacts after building with Gulp

snightingale

I had some geat help here a few weeks back which with gitlab ci as I have never used it before. I have come a decent way and now on my final section to have the output of Gulp to be contained within the artifacts zip.

So Currently my build .yml file looks like this:

cache:
  paths:
  - vendor/
  - node_modules/
before_script:
# Install git (the php image doesn't have it) which is required by composer
- apt-get update -yqq
- apt-get install git unzip -yqq
- apt-get install php-pear -yqq
# Install composer
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
# Setup PHPCompatibility for php_codesniffer
- mkdir --parents vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility
- cp -R vendor/wimg/php-compatibility/* vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility
stages:
- compatibility_test
- coding_standards
- gulp_build
- gulp_package
# Compatibility Test
PHP 5.2 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.2 src/ --report-full --report-summary --extensions=php
PHP 5.3 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.3 src/ --report-full --report-summary --extensions=php
PHP 5.4 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.4 src/ --report-full --report-summary --extensions=php
PHP 5.5 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.5 src/ --report-full --report-summary --extensions=php
PHP 5.6 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.6 src/ --report-full --report-summary --extensions=php
PHP 7.0 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 7.0 src/ --report-full --report-summary --extensions=php
PHP 7.1 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 7.1 src/ --report-full --report-summary --extensions=php
# # Coding Standards Test
PHP Coding Standards:
  image: php:5.6
  stage: Coding Standards
  script:
  - vendor/bin/phpcs -s --standard=ruleset.xml src/ --report-full --report-summary --extensions=php
JS Coding Standards:
  image: php:5.6
  stage: Coding Standards
  script:
  - vendor/bin/phpcs -s --standard=ruleset.xml src/js/ --report-full --report-summary --extensions=js
CSS Coding Standards:
  image: php:5.6
  stage: Coding Standards
  script:
  - vendor/bin/phpcs -s --standard=ruleset.xml src/css/ --report-full --report-summary --extensions=css
# Gulp Build
Gulp:
  image: node:latest
  stage: gulp_build
  script:
  - npm install -g gulp
  - npm install
  - gulp build
  - gulp zip
  artifacts:
    name: "my-build"
    expire_in: 1 week
    paths:
    - "dist/*"    

As you see its a bit of a beast but it works. The last part I have Gulp:

# Gulp Build
    Gulp:
      image: node:latest
      stage: gulp_build
      script:
      - npm install -g gulp
      - npm install
      - gulp build
      - gulp zip
      artifacts:
        name: "my-build"
        expire_in: 1 week
        paths:
        - "dist/*"  

Currently when the artifacts file is produced its name is show as my-build.zip which is perfect. However the folder directly within it is dist. Is there a way to change the dist folder to my-build?

Cheers,

Stu

snightingale

After some help from Gitlab Reddit I managed to resolve my issue. THis is what I did:

Gulp:
    only:
    - master
    - merge-requests
    image: node:latest
    stage: gulp_build
    script:
    - npm install -g gulp
    - npm install
    - gulp build
    - mv -T dist my-build
    - gulp build --premium
    - mv -T dist my-build-premium
    artifacts:
      name: "my-build"
      expire_in: 1 week
      paths:
      - my-build/
      - my-build-premium/

As it is an instance, I renamed the folder to what I wanted it to be called and then add it to the artifacts. I could now have a premium build there too along with only using Gulp on Master and merge-requests :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Gitlab Ci saving artifacts after running gulp

Gitlab ci artifacts not found

gitlab ci: Pass artifacts from two jobs of the same stage

How do I run my docker image from .gitlab-ci.yml after building the image?

Gitlab CI Angular Artifacts not accessible

Upload Gitlab CI artifacts to a storage outside Gitlab

Env vars lost when building docker image from Gitlab CI

gitlab-ci with Golang do not create the right folder structure

Gitlab ci - differences in artifacts app jar

Managing (older) CI artifacts in GitLab CE Omnibus

What is the correct usage of cache/artifacts in Gitlab CI?

GitLab CI Build not uploading artifacts of codeception

Is there a way to upload GitLab CI artifacts to an Openshift container?

gulp building css in dependency to folder

Remove artifacts from CI manually

How to download artifacts built with gulp script in azure-pipelines from dist folder

GitLab CI/CD change Folder & Folder rights

How to install dependencies after automatic deployment from GitLab CI/CD

Dynamically create gitlab-ci variables starting from a script

GitLab CI/CD: building multiarch Docker images

Only Single GitLab CI Runner Building

GitLab CI-Build Artifacts command line download

Where does Gitlab CI build stores artifacts into runner?

How to specify wildcard artifacts subdirectories in .gitlab-ci.yml?

Different artifacts when job succeeded and failed with GitLab CI

Send Gitlab-CI artifacts via e-mail

How to construct urls for job names for downloading latest artifacts in GitLab CI?

Gitlab CI/CD cross project artifacts not downloading using "needs"

Building and pushing docker image from Gitlab-CI to Amazon AWS ECR