Bitbucket Pipeline, Artifacts between steps - bitbucket

I am trying to use the following pipeline in bitbucket to deploy to gcloud. The rest of the pipeline is missing but I know that works. The issue is when I get to step two the compiled CSS files are no longer existing. It appears to match what bitbucket suggest for using artifacts. I tried the following;
artifacts:
- **
-public/assets/css/generated/style.css
-public/assets/css/generated/*.css
-public/assets/css/generated/*
-public/*
-public/**
.
pipelines:
branches:
pipeline:
- step:
image: node:4.6.0
caches:
- node
script:
- cd web-application
- npm install
- npm install -g gulp
- gulp
- ls public/assets/css/generated
# - mv public/assets/css/generated/* ~/./
- cd ..
artifacts:
- public/assets/css/generated/style.css
- public/**
- step:
image: google/cloud-sdk:latest
script:
- cd web-application
- ls public/assets/css/generated
Artifacts showing in step 1

Related

Bitbucket Pipelines Run Migrations After Deployment

I've setup a bitbucket pipeline successfully. The issue I'm having is how to run my database migrations after deployment has been completed. I'm using git-ftp. Specifically, I wish to cd into my directory via FTP, and run my migrations, like php vendor/bin migrate
image: wagnerstephan/bitbucket-git-ftp:latest
pipelines:
custom:
init:
- step:
caches:
- node
script:
- git reset --hard
- git ftp init -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST
deploy:
- step:
caches:
- node
script:
- git reset --hard
- git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST --all
branches:
master:
- step:
name: Deploy production
deployment: production
caches:
- node
script:
- git reset --hard
- git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST
- step:
name: 'Migrations'
image: php:7.4-fpm
script:
- # cd into my FTP server folder
- # run migrations
- php /public_html/home.php
I've searched around, but cannot seem to find a tutorial on this

Curl output to file during bitbucket pipeline and heroku deploy

I am trying to create curl request and the result of it i try to save to a file. All this happens during the pipeline.yml runs of bitbucket.
I am using this command:
- curl -X GET "https:myurl.com/file.json" -o ./filefolder/file.json
which works in local and i can even see it that it runs succesfully in pipeline, but the file is not created or it dissapears. I checked also in heroku folders and seems that the file is not there.
Configuration of .yml;
branches:
development:
- parallel:
- step:
name: Run build
caches:
- node
script:
- curl -X GET "https:myurl.com/file.json" -o ./filefolder/file.json
- export NODE_OPTIONS=--max-old-space-size=3072
- npm install
- npm run build
- npm test
- step:
name: "Zip the sources"
script:
- mkdir heroku
- tar -czf ../tmp/123.tar.gz .
- cd heroku
- mv ../../tmp/123.tar.gz .
artifacts:
- heroku/**

How to perform install only once under multiple stages?

I want to avoid perform install process times under multiple stages. My travis-ci config as follow, how to avoid run install process both in test and deploy stage? Beacause install is time-cost.
os: linux
language: android
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
android:
components:
- tools
- platform-tools
- build-tools-28.0.3
- android-28
jdk: oraclejdk8
sudo: false
install:
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- export PATH=$PATH:./flutter/bin
- flutter doctor
cache:
directories:
- "$HOME/.pub-cache"
stages:
- test
- name: depoly
if: tag =~ /^release-v\d+\.\d+\.\d+/ # tag match: release-v1.0.0
jobs:
include:
- stage: test
- script: flutter analyze lib/ test/
- script: flutter test test/
- stage: depoly
- script: flutter build apk
deploy:
provider: releases
api_key:
secure: $github_deploy_api_key
file: $APK_NAME
skip_cleanup: true
overwrite: true
on:
repo: stefanJi/Flutter4GitLab
branch: master

How to make TravisCI run flow/test/lint in parallel?

In my .travis.yml I have this.
script:
- yarn lint
- yarn flow
- yarn test --runInBand
I was wondering is there a way to get them to run in parallel?
There's few suggestions in Travis docs you could use, i.e. split your build into multiple jobs: https://docs.travis-ci.com/user/speeding-up-the-build/
Another thing you could do is to employ GNU parallel:
addons:
apt_packages:
- parallel
script:
- parallel --gnu --keep-order ::: 'yarn lint' 'yarn flow' 'yarn test --runInBand'
The GNU parallel command has lots of options you might want to tweak to your needs. Read more about the tool on their website https://www.gnu.org/software/parallel/
To split Travis into several jobs you can either use stages or add the option env
This would run each script sequentially:
script:
- yarn lint
- yarn flow
- yarn test --runInBand
- yarn build
- yarn cypress
To get them to run in parallel jobs. You can update it to the code below (Though keep in mind this is limited by the number of concurrent jobs available. https://travis-ci.com/plans)
Using Build Stages
language: node_js
node_js:
- '9'
install:
- travis_retry yarn install
jobs:
include:
- stage: test
name: "Flow/Lint/Test"
script:
- yarn lint
- yarn flow
- yarn test
-
name: "Cypress"
script:
- yarn cypress
Using env
env:
- TEST_SUITE="yarn lint"
- TEST_SUITE="yarn flow"
- TEST_SUITE="yarn test --runInBand"
- TEST_SUITE="yarn build"
- TEST_SUITE="yarn cypress"
script: $TEST_SUITE
Another option would be to just have two concurrent builds.
env:
- TEST_SUITE="yarn lint && yarn flow && yarn test --runInBand && yarn build"
- TEST_SUITE="yarn cypress"
script: $TEST_SUITE
This might or might not improve the overall build times. For me majority of my build time was in cypress while lint + flow + test took a few minutes. So by separating cypress to be in its own job, I sped up my overall build time by a few minutes.

How to exclude stage/job conditionally with travis build stages (beta feature)

Trying to get travis to skip release stage for PR/non master branch builds but I can't seem to get the recipe right.
The travis config is listed here:
language: node_js
cache:
directories:
- node_modules
node_js:
- '8'
- '6'
before_install:
- npm install -g npm#5
- npm install -g greenkeeper-lockfile#1
install:
- yarn install --ignore-engines
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
script:
- yarn coveralls
branches:
except:
- /^v\d+\.\d+\.\d+$/
jobs:
include:
- if: branch = master
- stage: release
node_js: lts/*
script: echo "Deploying to npm ..."
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
I also tried
jobs:
include:
- stage: release
if: branch = master
node_js: lts/*
script: echo "Deploying to npm ..."
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
and
jobs:
include:
-
if: branch = master
- stage: release
node_js: lts/*
script: echo "Deploying to npm ..."
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
but travis always executes the release stage - it doesn't run npx semantic-release but it still goes through initializing, running tests etc.

Resources