i have trouble with gitlab Continous integration. in localhost it yarn start work without problem even unit-test yarn berry version 2.4.2
my .yarnrc.yml
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-2.4.2.cjs
how to install a specific version of yarn in gitlab with gitlab-ci.yml please ?
I tryed with this different configuration and all failed
my gitlab-ci.yml
...
unit-tests:
stage: test
image: node:15.2.1-alpine3.11
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn/
script:
- yarn set version 2.4.2
/* tested also with
yarn set version https://cdn.jsdelivr.net/npm/2.4.2#1.0.0/
yarn set version 2.4.2.cjs
yarn set version https://cdn.jsdelivr.net/npm/2.4.2
*/
- yarn install
- yarn build
- yarn test
the error
00:01
Using docker image sha256:7ddc154413f500a1ec545a38fe661bf0fd138e061495e5786ef017352b52c52d for node:15.2.1-alpine3.11 with digest node#sha256:7614f96f47ede63333a7ddbd31c71207956eb39b641e724f81c198c067bacf41 ...
$ yarn set version 2.4.2.cjs
Resolving 2.4.2.cjs to a url...
error An unexpected error occurred: "Release not found: 2.4.2.cjs".
this is a solution : using yarn set version 2.4.2alone don't work
.gitlab-ci.yml
stages:
- test
- release
unit-tests:
stage: test
image: node:15.2.1-alpine3.11
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn/
script:
- yarn set version berry <--- get last version
- yarn set version 2.4.2 <--- then downgrade to a specific version
- yarn install
- yarn build
- yarn test
...
Dockerfile ( for build in CI)
...
ENV NODE_ENV production
RUN yarn set version berry
RUN yarn set version 2.4.2
RUN yarn install
...
Related
I'm having trouble automating react native release build apps using firebase app distribution with Gitlab CI/CD. I get this error Error: set the --app option to a valid Firebase app id and try again
Also see image:
I've setup ".gitlab-ci.yml" file as below
## install project deps with --frozen-lockfile to make sure we will have the same packages version ( very recommended on running yarn install on ci)
##run: yarn install --frozen-lockfile
before_script:
- yarn install --frozen-lockfile
- yarn global add firebase-tools
stages:
- buildApp
buildApp project:
stage: buildApp
image: reactnativecommunity/react-native-android
cache:
key:
files:
- yarn.lock
paths:
- node_modules
policy: pull #`pull` the jobs pull the cache at the beginning but do not push the changes again.
script:
- yarn build:apk
- yarn install --pure-lockfile --cache-folder .yarn
- ./bin/app_distribution.sh
# - firebase use kavyatara --token "$FIREBASE_TOKEN"
# - firebase deploy --token "$FIREBASE_TOKEN"
artifacts:
paths:
- android/app/build/outputs/apk/release/app-release.apk
Also
app_distribution.sh file
#!/bin/bash
RELEASE_NOTE="New update Android build"
firebase appdistribution:distribute android/app/build/outputs/apk/release/app-release.apk \
--token "$FIREBASE_TOKEN" \
--app "$FIREBASE_APP_ID" \
--release-notes "$RELEASE_NOTE" --testers-file testers.txt
I have a simple .gitlab-ci.yml file that builds my Vue application. I build once and then deploy the dist folder to my various environments:
stages:
- build
- deploy_dev
- deploy_stg
- deploy_prd
build:
image: node:latest # Pull Node image
stage: build
script:
- npm install -g #vue/cli#latest
- npm install
- npm run build
artifacts:
expire_in: 2 weeks
paths:
- dist/
deploy_to_dev:
image: python:latest
stage: deploy_dev
dependencies:
- build
only:
- master # Only deply master branch automatically to Dev
script:
- export AWS_ACCESS_KEY_ID=$DEV_AWS_ACCESS_ID
- export AWS_SECRET_ACCESS_KEY=$DEV_AWS_ACCESS_KEY
- pip install awscli # Install AWS CLI
- aws s3 sync ./dist s3://$DEV_BUCKET
This all works great, however, I've now introduced some config and build my app differently per environment - for 3 environments I have 3 different build commands. Eg, I have an .env.production so for a production build my command becomes:
npm run build -- --mode production
Is there any way to get around having different builds for each environment but still using the .env files based on a GitLab variable?
You should split your build job to have one per environment and use the environment concept to have something like that for dev and production envs :
.build_template: &build_template
image: node:latest # Pull Node image
script:
- npm install -g #vue/cli#latest
- npm install
- npm run build -- --mode $CI_ENVIRONMENT_NAME
build_dev:
stage: build_dev
<<: *build_template
environment:
name: dev
build_prod:
stage: build_prod
<<: *build_template
environment:
name: production
In this snippet, I used anchors to avoid duplicate lines.
I'm setting up a GitHub action with following steps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- uses: borales/actions-yarn#master
with:
cmd: install # will run `yarn install` command
- uses: actions/setup-node#master
with:
node-version: '12.x'
- run: npm run build:prod
It crashes on building the app becuase of OS mismatch on Node Sass library
./node_modules/font-awesome-loader/font-awesome.config.js) Module
build failed (from ./node_modules/sass-loader/dist/cjs.js): Error:
Missing binding
/home/runner/work/xxx/xxx/node_modules/node-sass/vendor/linux-x64-72/binding.node
Node Sass could not find a binding for your current environment:
Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
- Linux/musl 64-bit with Node.js 12.x
Running npm rebuild node-sass as a step causes errors since the agent does not have admin permissions.
Any idea why Github-Actions is giving me linux/musl instead of linux?
The issue was with mixing yarn and npm. I was using yarn to install and npm to build. Doing both with yarn solved the problem.
Since there is already a saved cache for node_modules when the Pipeline is run, it does not make the npm install so new dependencies are not installed. Because of this, while the Pipeline is still running, it suddenly breaks as project does not find the corresponding package.
pipelines:
custom:
deploy-staging:
- step:
name: install dependencies
caches:
- node
script:
- npm install
- step:
name: deploy to all STAGING themes
deployment: staging
caches:
- node
- globalnode
script:
- npm run deployall -- -t staging
How could I fix that?
I'm trying to setup my first Bitbucket pipeline which simply builds my application and deploys it to my FTP server using the following bitbucket-pipelines.yml
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script:
- npm install
- npm test
- step:
script:
- npm run build
- node deploy.js
The issue lies in the npm install because when bitbucket tries to run the npm run build command it says that rimraf (a npm package) is not found. rimraf however is listed in my devDependencies, all regular dependencies in my package.json are downloaded correctly.
There is no global variable set by my so the NODE_ENV could not be it right?
I had the same issue with gulp.
Gulp was in devDependencies and also specified in package.json as script but still it said npm ERR! missing script: gulp
The documentation says to install it globally, so there might be a related issue with your package.
https://confluence.atlassian.com/bitbucket/javascript-node-js-with-bitbucket-pipelines-873891287.html
I had this same issue. For me, the problem was that the version of Node on my local development device was different from the version of Node in the bitbucket-pipelines.yml file.
To fix it, I went into bitbucket-pipelines.yml and changed this line:
image: node:10.15.3
to this:
image: node:14.15.0