CircleCI Error migrating config to version 2 - migration

I am trying to migrating circleci 1.0 to 2.0 ,
and I got this error.
in job ‘build’: steps is not a list
can someone help me what is the reason ?
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.2.3-jessie
environment:
AWS_REGION: eu-central-1
steps:
- checkout
- run: echo "Tests are skipped because of static site."
- run: mkdir -p /tmp/test-data
deploy:
production:
branch: master
commands:
- bundle exec middleman s3_sync

The identation of the array below steps seems to be off. Try this:
steps:
- checkout
- run: echo "Tests are skipped because of static site."
- run: mkdir -p /tmp/test-data

Related

Upload artifacts to aws from circle ci

I have created this yam file to create a binary image for my iot board with circle ci..
version: 2.1
orbs:
python: circleci/python#1.4.0
jobs:
build:
executor: python/default
steps:
- checkout # checkout source code to working directory
- run:
name: Install PlatformIO
command: pip install --upgrade platformio
- run:
name: Compile Project
command: pio run
- run:
name: Creating Dummy Artifacts
command: |
cd .pio/build/esp32dev
echo "firmare.bin" > /tmp/art-1;
mkdir /tmp/artifacts;
echo "my artifact files in a dir" > /tmp/artifacts/art-2;
- store_artifacts:
path: /tmp/art-1
destination: artifact-file
- store_artifacts:
path: /tmp/artifacts
workflows:
main:
jobs:
- build
I would like to store the artifact the firmware.bin in a bucket in aws...
Do you know how to do it or a similar example that I can check and modify ?
Thanks a lot
I guess the simple option is to use CircleCI's circleci/aws-s3 orb.

Docker Tag Error 25 on gitlab-ci.yml trying to start GitLab Pipeline

I'm going through the "Scalable FastAPI Application on AWS" course. My gitlab-ci.yml file is below.
stages:
- docker
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
cache:
key: ${CI_JOB_NAME}
paths:
- ${CI_PROJECT_DIR}/services/talk_booking/.venv/
build-python-ci-image:
image: docker:19.03.0
services:
- docker:19.03.0-dind
stage: docker
before_script:
- cd ci_cd/python/
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build -t registry.gitlab.com/chris_/talk-booking:cicd-python3.9-slim .
- docker push registry.gitlab.com/chris_/talk-booking:cicd-python3.9-slim
My Pipeline fails with this error:
See https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ docker build -t registry.gitlab.com/chris_/talk-booking:cicd-python3.9-slim .
invalid argument "registry.gitlab.com/chris_/talk-booking:cicd-python3.9-slim" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 125
It may or may not be relevant but the Container Registry for the GitLab project says there's a Docker connection error.
Thanks
I created a new GitLab account with a new username and things are working now. The underscore does appear to have been the issue.

Vue deployment to Heroku with CircleCI failing: fatal: Not a git repository (or any of the parent directories): .git

Having trouble deploying to HEROKU with CircleCI. I have already tested deploying git push heroku master to heroku manually, which is working. However when I use CircleCI, deployment no longer works.
Github repo url: https://github.com/dulerong/vue-test-circleci
I have set HEROKU environment variables in CircleCI project setting.
HEROKU_API_KEY=my_key
HEROKU_APP_NAME=my_app_name
Error message follows.
#!/bin/bash -eo pipefail
if false;then
force="-f"
fi
heroku_url="https://heroku:$HEROKU_API_KEY#git.heroku.com/$HEROKU_APP_NAME.git"
if [ -n "$CIRCLE_BRANCH" ]; then
git push $force $heroku_url $CIRCLE_BRANCH:main
elif [ -n "$CIRCLE_TAG" ]; then
git push $force $heroku_url $CIRCLE_TAG^{}:main
else
echo "No branch or tag found."
exit 1
fi
fatal: Not a git repository (or any of the parent directories): .git
Exited with code exit status 128
CircleCI received exit code 128
Below is my circleCI config.yml
version: 2.1
orbs:
heroku: circleci/heroku#1.2.5
jobs:
build-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- checkout
- run:
name: Install dependencies
command: npm install
- run:
name: Build
command: npm run build
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: lint
command: npm run lint
- run:
name: test
command: npm run test:unit
deploy-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- attach_workspace:
at: ~/repo
- heroku/deploy-via-git
workflows:
version: 2.1
deploy:
jobs:
- build-job
- deploy-job:
requires:
- build-job
filters:
branches:
only: master
I have linked CircleCI to my Github repo
I have created .circleci folder config.yml
I have created an app on heroku, which works when I deploy manually
The build part of my CircleCI works, however deployment does not work
Any help is appreciated, thanks in advance.
Found out what I was missing.
- checkout
I was missing this line of code in my deploy-job. Hence after changing the deploy-job yml config code to following, everything worked.
deploy-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- checkout<--- INSERT THIS CODE HERE!!!!
- attach_workspace:
at: ~/repo
- heroku/deploy-via-git
Reason: checkout command leads CircleCI to the root directory of your project. Hence without this line of code, you're looking at a folder directory that's not even the root of your project.
Other useful command include
- run:
name: show directory
command: pwd
- run:
name: look in directory
command: ls -ltr
If you place those commands beneath checkouk, and look into the job progress in your CircleCI project, you can actually see which directory CircleCI is looking at, during that exact moment, very useful to check which directory CircleCI is working in. I put in those two commands and found out that my CircleCI was not looking at the root directory, hence discovering my problem.
Took me a few hours to figure this out!!!

gitlab ci yml run specific stage for release candidate branch only

Hi I have a yml as below but i want to run specific stage for only specific branch names like release candidate. The name of the release branch can change like cis-rel1.0 the next time cis-rel2.0 and so on.
image: java:8
stages:
- build
- deploy
build:
stage: build
script: ./mvnw package
artifacts:
paths:
- target/demo-0.0.1-SNAPSHOT.jar
production:
stage: deploy
script:
- curl --location "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar zx
- ./cf login -u $CF_USERNAME -p $CF_PASSWORD -a api.run.pivotal.io
- ./cf push
only:
- cis-rel1.0
Yes you can achieve that using the regex pattern in .gitlab-ci.yml as shown below . This regex will filter for your project name /^cis-rel.*$/
image: java:8
stages:
- build
- deploy
build:
stage: build
script: ./mvnw package
artifacts:
paths:
- target/demo-0.0.1-SNAPSHOT.jar
production:
stage: deploy
script:
- curl --location "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar zx
- ./cf login -u $CF_USERNAME -p $CF_PASSWORD -a api.run.pivotal.io
- ./cf push
only:
- /^cis-rel.*$/

Using redis with Gitlab CI

I am currently using serverless framework and setting up gitlab ci using shared runner.
Following is my gitlab-ci.yml:
image: node:latest
services:
- redis
cache:
paths:
- node_modules/
- java/
stages:
- build
- test
- review
- staging
- production
build:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
install:java:
stage: build
script:
- apt-get update
- apt-get install -y default-jre default-jdk openjdk-7-jre openjdk-7-jdk
- apt-get update
- sls dynamodb install
artifacts:
paths:
- java/
connect:
image: redis
script:
- redis-cli -h redis PING
unit test:
stage: test
script:
- sls dynamodb start
- babel-node ./aws/createDB.js
- npm run unit
dependencies:
- build
- install:java
unit test job requires redis and is not able to connect. Following error gets thrown, when unit test job starts:
Error while creating redis client: Error: Redis connection to
127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
Can someone point out what's wrong with current config file, thanks!
The host address of the redis service is redis not 127.0.0.1 or localhost.
So make sure you set the host for the redis service to redis in all of your scripts and configuration files.
Just to make people's life easier, I list an example .gitlab-ci.yml to configure Redis in Gitlab CI.
services:
- redis:latest
stages:
- test
test:
script:
- echo "hello world!"
stage: test
variables:
REDIS_PORT: 6379
REDIS_HOST: redis
REDIS_URL: redis://redis:6379