Gitlab pipeline fails since the package.json has windows commands - gitlab

I am working on a cypress project. The package.json has commands to delete old report folder and create new folder with same name.
I achieve this by using windows commands in package.json:
“Clean-reports”: “rmdir /s /q cypress\reports && mkdircypress\reports”
“Test”:”npm run Clean-reports && cypress run”
But when running this project on gitlab pipeline It gets stuck on rmdir command.
How do we achieve directory deletion and creation when running tests over gitlab pipeline ??

If you have Git for Windows, you have 200+ Linux command accessible in <Path\to\GIt>\usr\bin
That includes command rm.exe
Your Clean-reports steps can then become:
rm -Rf cypress\reports && ...
That command would be interpreted in a Linux environment.

Related

How to covert rm command for Windows environment?

Cypress manual for configuring Reporters contains rm command which doesn't work in Windows, namely
rm cypress/results/* || true
I believe that this is the manual bug regarding using Linux command in Windows environment, so the question is how it can be done in Windows? Moreover, I suppose to use the config file containing this command in Docker container which uses Linux core I believe. So the another problem is if I convert the command for Windows will I be able to use this file in my Docker container? Could somebody point me out the right way of using this command for the both OS? here is the link to Cypress manual containing this command https://docs.cypress.io/guides/tooling/reporters#Examples
rmdir can be used in windows
"delete:reports": "rmdir /S /Q cypress\\results && mkdir cypress\\results",
I do not think this will work for docker.
Cross platform,
yarn add -D rimraf mkdirp
"delete:reports": "rimraf cypress/results && mkdirp cypress/results",

How to create a batch file which runs multiple maven, CMD, and node commands?

I have a use case where I need to deliver an application to a client as a one-click executable so that he doesn't have to perform multiple operations to setup and run the application.
Obviously, I can host it using hiroku or any other hosting service but I'm running short on time.
My application consists of - Angular5 frontend + Spring boot middleware + MongoDB backend
The repository is on github. Also, I have separate backend and frontend. So the sequence of commands in bat file are:
git clone - my repository.git
cd backend-app > mvn spring-boot:run
cd.. > cd frontend-app > npm install > npm build(or start)
Open browser.
Here is what I came up with:
echo off
call git clone https://github.com/saranshbansal/xyz.git
cd angular-frontend
call npm install && npm build
cd..
cd spring-boot-backend
call mvn spring-boot:run
cmd explorer "http://localhost:4200/"
However, this bat file only executes the first command and exits. It doesn't execute rest of the commands. I've tried changing the order but the result is same.
Please help in fixing it.

Visual Studio Team Services FTP upload output of npm run build:prod

Using the CI stack builder in Visual Studio Team Services I was able to do an FTP upload from a repository and I was able to separately run npm install and npm run build:prod - however how do I join these two?
I want to run:
npm install
npm run build:prod
FTP upload the results of step 2
The problem I'm having is I have no idea how to access the results of the build command as the FTP command is asking which path to upload and only lets me choose existing paths in my repository.
Edit: When I run the build command on a local machine it creates a folder 'dist' in the root with the build output and I want to upload this output using FTP to a server.
Thanks
You just need to specify the dist folder related path of source directory (e.g. XXX\1\s)
For example:

How run npm on deploy project via git? (hooks/post-receive: npm: command not found)

Problem
I created a project where configure a server in DigitalOcean with Apache and Git.
For init project on server, I run the following command:
cd /var/repo
mkdir project-example.git && cd project-example.git
git init --bare
I set up file post-receive with this code:
#!/bin/bash
git --work-tree=/var/temp/project-example --git-dir=/var/repo/project-example.git checkout -f
cd /var/temp/project-example
npm install
npm run build
rm -rf /var/www/project-example/*
mv -f /var/temp/project-example/build/* /var/www/project-example/
When I make a push to server remote via git on machine local, occurs followings errors:
remote: hooks/post-receive: line 4: npm: command not found
remote: hooks/post-receive: line 5: npm: command not found
However, accessing server via SSH and execute command:
# it works standard
cd /var/repo/project-example.git
source hooks/post-receive
Comments
System Server: Ubuntu 14.04
I installed node via nvm.
When a git hook runs, it does not necessarily have the same PATH variable set as when you log in via SSH. Try putting the full path to npm in your script when you call it; that should fix things.
UPDATE (June 7 2019):
A couple of commenters had issues with node not being found when using the above solution, which made me realize it is not very robust. Rather than put the path in the call to npm itself, you'd be better off adding the necessary path to the script's environment, e.g. if npm (and node) happen to be in /usr/bin/, add the following to your script before calling npm:
export PATH=$PATH:/usr/bin
In fact, a more robust way to make sure the hook works the same as it does when you are logged in via SSH is to find out what the path is when you are logged in (i.e. the output of echo $PATH) and set the path in your hook script accordingly (of course you may need to omit some user-specific paths, etc.)

Gulp running on OSX & Windows

I'm new with Gulp, I have created my project in windows and installed/configured everything in my gulpfile, everything works fine.
My project is synchronized with Google Drive between my Windows 8 PC and macbook.
But when I run "gulp" command in osx this isn't working
"Error: Cannot find module 'loadash.basevalues'
Node is installed in OSX and on a different project that I created in OSX it is working fine. Am I missing something? Sorry if this is a dumb question, but I can't find anything about this in Google
You should not move node_modules folder between your environments. Package.json file should contain all data and package names for you dependencies.
You can set up free remote git repository on services like github or gitlab, add .gitignore file inside root of your project, specify inside folders to exclude (node_modules obviously) and send it on remote git repository with "git push" command, to "git pull" any updates from your second location.
Remove entire node_modules folder on your OSX and run "npm install" or shorted "npm i". You might want to check if your node and npm versions are matching with "node -v" or "nodejs -v" and "npm -v" commands - if these versions are much different, consider to update your environment.

Resources