0

i have created a pipeline to deploy my angular app to my ftp server through bitbucket pipeline. I have created therefore this pipeline.yml file:

 image: node:6.9.4 # we need node image to run our angular application in 
  clone: # help to clone our source here
  depth: full
 pipelines: # We set up all the pipeline or actions beneath 
default: # here most always trigger before any other pipeline 
  - step:
      script:
        - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'." 

branches: # This is branch specific configuration, we can set for different branches and different actions when we push codes
  master:
    - step:
        script: 
          - npm install -g @angular/cli 
          - npm install 
          - ng build --prod
          - echo "Let's go in to our dist/ and initialize there with git"
          - cd dist/ 
          - git config --global user.email "[email protected]"
          - git config --global user.name "clate"
          - git init
          - git add -A && git commit -m "base url updated for prod deployment" 
          - git clone https://github.com/git-ftp/git-ftp.git
          - cd git-ftp 
          - git checkout 1.3.4
          - make install
          - echo "Done with installation of git-ftp"
          - cd ../
          - rm -rf git-ftp
          - git config git-ftp.url "ftp://188.40.30.32/test"
          - git config git-ftp.user $FTP_USERNAME
          - git config git-ftp.password $FTP_PASSWORD
          - git ftp push --auto-init

Unfortunately i'm receiving an error while trying to run command ng build --prod It is showing this error:

+ ng build --prod
/usr/local/lib/node_modules/@angular/cli/bin/ng:23
 );
 ^
SyntaxError: Unexpected token )
  at Object.exports.runInThisContext (vm.js:76:16)
  at Module._compile (module.js:542:28)
  at Object.Module._extensions..js (module.js:579:10)
  at Module.load (module.js:487:32)
  at tryModuleLoad (module.js:446:12)
  at Function.Module._load (module.js:438:3)
  at Module.runMain (module.js:604:10)
  at run (bootstrap_node.js:394:7)
  at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

i haved tried to run it locally and it works without any problems.

1 Answer 1

3

you have angular cli installed in your project, the better and faster way would be to use local ng installation to build your project. just add an npm script and call build through npm like this:

//package.json
"scripts": {
 "build:prod": "ng build --prod",
...
}


pipeline.yml

       - npm install -g @angular/cli <---THIS IS NO LONGER NEEDED
       - npm install
       - npm run build:prod
....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.