CircleCI getting an error on running a make command - makefile

I want to config.yml that has a "build" and "test" jobs.
We have a Makefile in our docker image but it seems it's not finding the make file since I'm always getting this error
#!/bin/bash -eo pipefail
make test
make: *** No rule to make target 'test'. Stop.
Exited with code exit status 2
CircleCI received exit code 2
Is anyone familiar with this? I'm not sure what I have missed.
Thank you!
Here is the yml file:
version: 2.1
workflows:
my-workflow:
jobs:
- build:
context: circleci-aws-credentials
- test
jobs:
build:
docker:
- image: circleci/openjdk:11-jdk
working_directory: ~/my-project
environment:
# Customize the JVM maximum heap limit
JVM_OPTS: -Xmx3200m
steps:
- checkout
# Download and cache dependencies
- restore_cache:
key: my-project-service-{{ checksum "./build.gradle" }}
test:
docker:
- image: circleci/openjdk:11-jdk
working_directory: ~/my-project
environment:
# Customize the JVM maximum heap limit
JVM_OPTS: -Xmx3200m
steps:
- run:
name: Gradle test
command: make test
- store_test_results:
path: ./build/test-results
Thank you for your help in advance!

Related

Container 'docker' exceeded memory limit

Hi I have the following pipeline config
image: maven:3.3.9
definitions:
steps:
- step: &build-step
name: SonarQube analysis
script:
- pipe: sonarsource/sonarcloud-scan:1.4.0
variables:
SONAR_HOST_URL: ${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
SONAR_SCANNER_OPTS: -Xmx1024m
SONAR_TOKEN: ${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
caches:
sonar: ~/.sonar
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- step: *build-step
I want to increase the size of the docker to 2x could you please help with the proper YML config for the same?
I tried changing it to
- step:
size: 2x
but it won't work, I get erros that step is null or missing

Can't get CircleCI to post to Slack upon test failure

I'm getting no parsing errors and i believe my config.yml is correct, I just can't seem to get it to post to slack, i have all the backgrounc config correct such as the environment variables and the context part is what we call to our organization settings, it's just not posting upon failure, is there something i'm doing wrong?
version: 2.1
orbs:
cypress: cypress-io/cypress#1
slack: circleci/slack#4.5.0
workflows:
version: 2
test:
jobs:
- cypress/run
jobs:
steps:
executors:
with-chrome:
docker:
- image: 'cypress/browsers:node14.16.0-chrome90-ff88'
description: Runs cypress tests
steps:
- checkout
- run:
name: Run all cypress tests
command: npx cypress run
context: slack-context
- slack/notify:
event: fail
template: basic_fail_1
It appears you're using the CircleCI Cypress orb, and more specifically the cypress/run job defined in that orb. So I'm not sure what the part
jobs:
steps:
executors:
with-chrome:
docker:
- image: 'cypress/browsers:node14.16.0-chrome90-ff88'
description: Runs cypress tests
steps:
- checkout
- run:
name: Run all cypress tests
command: npx cypress run
context: slack-context
- slack/notify:
event: fail
template: basic_fail_1
is for.
The way your config looks, that part will never be executed. Your build will be simply the cypress/run job running with all the default parameters' values.
Further more, contexts need to be referenced within the workflows section (https://circleci.com/docs/2.0/contexts/).
I would suggest the below configuration:
version: 2.1
orbs:
cypress: cypress-io/cypress#1.29.0
slack: circleci/slack#4.10.1
executors:
with-chrome:
docker:
- image: 'cypress/browsers:node14.16.0-chrome90-ff88'
workflows:
version: 2
test:
jobs:
- cypress/run:
executor: with-chrome
browser: chrome
context: slack-context
post-steps:
- slack/notify:
event: fail
template: basic_fail_1

How to configure aliases in YAML?

I'm trying to write some aliases into my YAML file but I keep getting an error. How can I configure aliases in YAML?
...rest_of_code
# DEFAULTS
checkout-and-attach: &checkout-and-attach
checkout:
path: ~/app
attach_workspace:
at: ~/app
# iOS Build and Test
build-and-test:
macos:
xcode: "10.2.0"
working_directory: ~/app/ios
steps:
<<: *checkout-and-attach # [ERROR]: Incorrect type expect array
...rest_of_code
I didn't find a way to spread an array with circleci.
In addition, I think that the references section must be before the jobs section.
Example for working config.yml with reference:
version: 2
references:
init_aws: &init_aws
run:
name: Init aws credentials
command: echo 1
init_env_vars: &init_env_vars
run:
name: Init environment variables
command: echo 2
jobs:
build:
docker:
- image: circleci/node:8.11.3
steps:
- *init_aws
- *init_env_vars

Yaml : Formatting error in yaml file. expected '<document start>', but found '<block mapping start>

version: 2.1
executors:
docker-publisher:
environment:
IMAGE_NAME: vinaya.nayak/mocking-service
docker:
- image: circleci/buildpack-deps:stretch
jobs:
build:
executor: docker-publisher
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o mocking.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./mocking.tar
publish-latest:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/mocking.tar
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
docker push docker.kfz42.de/v2/java/mocking-service/$IMAGE_NAME:latest .
workflows:
version: 2
build-master:
jobs:
- build:
filters:
branches:
only: master
- publish-latest:
requires:
- build
filters:
branches:
only: master
can some one help me with whats wrong with my yaml file. I get the following error. I even tried using yaml formatter and the yaml formatter says that this is a valid yaml file
!/bin/sh -eo pipefail Unable to parse YAML expected '', but found '' in 'string', line 39,
column 1: workflows: Warning: This configuration was auto-generated to
show you the message above. Don't rerun this job. Rerunning will have
no effect. false Exited with code 1
Your file starts with a key-value pair indented with two spaces, so you have a root level node that is a mapping. That is fine as long as all other root level are indented two spaces as well.
workflows is not indented, that is why the parser expected a new document.
version: 2.1
executors:
docker-publisher:
environment:
IMAGE_NAME: vinaya.nayak/mocking-service
docker:
- image: circleci/buildpack-deps:stretch
jobs:
build:
executor: docker-publisher
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o mocking.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./mocking.tar
publish-latest:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/mocking.tar
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
docker push docker.kfz42.de/v2/java/mocking-service/$IMAGE_NAME:latest .
workflows:
version: 2
build-master:
jobs:
- build:
filters:
branches:
only: master
- publish-latest:
requires:
- build
filters:
branches:
only: master
I fixed the above problem by indenting workflows with 2 spaces

Runnig tasks only when merging to master

I use the following config which works as expected, it run the command on each PR or merge to the master, Now I want to make some integration test which I want to run only when merged to the master, all the PR should remain the same (and run the following config as before). the nuance here is that for the integration test I need other docker image and different run command to execute (which should execute only when merging to the master), is it possible to do it with CircleCI ?
# Golang CircleCI 2.0 configuration file
version: 2
jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.11
working_directory: /go/src/sbr
steps:
- checkout
- run: go version
- run: go env
- run: go get -v -t -d ./...
- run: go test -v ./...
I try to add another docker image under the existing one but I got error
update:
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.11
working_directory: /go/src/sbr
steps:
- checkout
- run: go version
- run: go env
- run: go get -v -t -d ./...
- run: go test -v ./...
test-integration:
docker:
- image: other-image
workflows:
version: 2
builds:
jobs:
- build
integration-test:
jobs:
- test-integration:
requires:
- build
filters:
branches:
only: master
The issue here that I got error when adding to the second workflow the require
requires:
- build
I want that before the test test-integration it will also run the build job as per-requiste . what im doing wrong ?
The error is:
requires job \"build\" but \"build\" is not part of this workflow.
# At least one job in the workflow must have no dependencies.
# The following jobs are unreachable: integration
#
# -------
# Don't rerun this job. Rerunning will have no effect.
false
Your configuration has a single job named build and no workflows. It sounds like what you want is to run a second job for integration tests, and to have the second job only run when the branch is master. To accomplish both of those you would use a workflow with two jobs.
See https://circleci.com/docs/2.0/configuration-reference/#workflows
An example of what that might look like:
jobs:
build:
docker:
- image: circleci/golang:1.11
...
test-integration:
docker:
- image: other-image
...
workflows:
version: 2
workflow-name:
jobs:
- build
- test-integration:
filters:
branches:
only: master

Resources