Is there a way to change the directory in AWS codebuild

When Snap-CI leaves, I try to get our builds to work on AWS CodeBuild. I have buildspec.yml, but changing directories doesn't work.

version: 0.1

phases:
  install:
    commands:
      - apt-get update -y
      - apt-get install -y node
      - apt-get install -y npm
  build:
    commands:
      - cd MyDir  //Expect to be in MyDir now
      - echo `pwd` //Shows /tmp/blablabla/ instead of /tmp/blablabla/MyDir
      - npm install //Fails because I'm not in the right directory
      - bower install
      - npm run ci
  post_build:
    commands:
      - echo Build completed on `date`
artifacts:
  files:
    - MyDir/MyFile.war
  discard-paths: yes

It seems like it should be pretty simple, but so far I have not been able to get this to work.

+4
source share
2 answers

If you change the buildspec.yml version to 0.2, the shell will save its settings. In version: 0.1 you get a clean shell for each command.

enjoy;)

+8
source

CodeBuild ( CODEBUILD_SRC_DIR).

:

  • : , buildspec (, ).

commands: - cd MyDir && npm install && bower install - cd MyDir && npm run ci

  • buildspec script ( ).

commands: - ./mybuildscipt.sh

, - .

- EDIT -

CodeBuild buildspec v0.2, .

+6

Source: https://habr.com/ru/post/1671290/


All Articles