Desperate help needed:
Already asked for the case with gitlab-runner register as "shell", I try to ask a very similar question here with gitlab-runner register as "docker".
Since 3 days I try to get Gitlab CI running (using docker, fastlane - all for an iOS-app having Cocoapods dependencies).
Here is the error message that the GitLab CI spits out:
I did the following steps:
install fastlane (link to fastlane page)
create a GitLab project and upload your project repository (link to GitLab)
install gitlab-runner on MacOS, following these steps...
install Docker (for desktop), registering here and downloading the app
register gitlab-runner (i.e. open terminal and type the following):
(your Token can be found under GitLab-->Settings-->CI/CD)
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "TOKENABCDEFG" \
--description "MyApp runner with ruby-2.6" \
--tag-list ios \
--executor "docker" \
--docker-image ruby:2.6
start docker application on your Mac
run docker image (by typing the following in your terminal:)
docker run -d --name gitlab-runner --restart always \
-v /Users/Shared/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
After all that, any git push to your GitLab project repo will automatically start a Pipeline.
I also tried using a local shell (instead of docker) - but no success either as documented here.
No matter what I try, I always end up with the same error message:
[08:48:04]: Driving the lane 'ios tests' 🚀
[08:48:04]: -----------------------
[08:48:04]: --- Step: cocoapods ---
[08:48:04]: -----------------------
[08:48:04]: Using deprecated option: '--clean' (true)
[08:48:04]: $ cd '.' && bundle exec pod install
[08:48:04]: â–¸ WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
[08:48:04]: â–¸ Consider adding the following to ~/.profile:
[08:48:04]: â–¸ export LANG=en_US.UTF-8
[08:48:04]: â–¸
[08:48:04]: â–¸ bundler: failed to load command: pod (/usr/local/bundle/bin/pod)
[08:48:04]: â–¸ CLAide::Help: [!] You cannot run CocoaPods as root.
Here is my .gitlab-ci.yml file:
stages:
- unit_tests
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
before_script:
- gem install bundler
- bundle install
unit_tests:
dependencies: []
stage: unit_tests
artifacts:
paths:
- fastlane/screenshots
- fastlane/logs
script:
- bundle exec fastlane tests
tags:
- ios
And here the Fastfile:
update_fastlane
default_platform(:ios)
platform :ios do
def install_pods
cocoapods(
clean: true,
podfile: "./Podfile",
try_repo_update_on_error: true
)
end
lane :tests do
install_pods()
gym(configuration: "Release",
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
clean: true,
output_name: "MyApp.ipa")
# increment_build_number
scan(workspace: "MyApp.xcworkspace",
devices: ["iPhone SE", "iPhone XS"],
scheme: "MyAppTests")
end
I finally found the solution:
Your gitlab-runner register is not allowed to have sudo.
For some reason there are many tutorials out there that show differently (i.e. with sudo) - such as this video or others...
Anyway, on a Mac you absolutely need to leave sudo out and absolutely register as "shell" executor for GitLab (i.e. not "docker")
Here is the best tutorial I have found on how to Gitlab CI an iOS project.
Related
when I build the ios project using this command in Flutter in github actions(by the way, using the same command in my local macOS catalina 10.15.7 and xcode 12.3 works fine):
./ios && bundle exec fastlane beta
shows this error:
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/runner/Library/Developer/Xcode/DerivedData/Runner-gzzbtgmsqethlzedjqlbspydxjjv/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh
(1 failure)
[05:17:23]: Exit status: 65
[05:17:23]:
[05:17:23]: Maybe the error shown is caused by using the wrong version of Xcode
[05:17:23]: Found multiple versions of Xcode in '/Applications/'
[05:17:23]: Make sure you selected the right version for your project
[05:17:23]: This build process was executed using '/Applications/Xcode_12.3.app'
[05:17:23]: If you want to update your Xcode path, either
[05:17:23]:
[05:17:23]: - Specify the Xcode version in your Fastfile
[05:17:23]: â–¸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[05:17:23]:
[05:17:23]: - Specify an absolute path to your Xcode installation in your Fastfile
[05:17:23]: â–¸ xcode_select "/Applications/Xcode8.app"
[05:17:23]:
[05:17:23]: - Manually update the path using
[05:17:23]: â–¸ sudo xcode-select -s /Applications/Xcode.app
[05:17:23]:
this is the fastlane, in this script, I specify the xcode version 12.3 :
xcversion(version: "12.3")
xcode_select("/Applications/Xcode_12.3.app")
if is_ci
create_keychain(
name: ENV['MATCH_KEYCHAIN_NAME'],
password: ENV["MATCH_KEYCHAIN_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: false
)
end
where is going wrong and what should I do to fix it? I have tried to execute the commad in github actions, this is my config:
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: '12.x'
- uses: subosito/flutter-action#v1
with:
flutter-version: '1.22.5'
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_12.3.app/Contents/Developer'
- name: Bundle install
run: cd ./ios && bundle install && bundle update fastlane
- name: Install tools
run: |
flutter precache
flutter pub get
cd ./ios && pod repo update && pod install
#- run: flutter pub get
#- run: flutter build apk
#- run: flutter build ios --release --no-codesign
- name: Setup SSH Keys and known_hosts for fastlane match
run: |
SSH_PATH="$HOME/.ssh"
mkdir -p "$SSH_PATH"
touch "$SSH_PATH/known_hosts"
echo "$PRIVATE_KEY" > "$SSH_PATH/id_rsa"
chmod 700 "$SSH_PATH"
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 600 "$SSH_PATH/known_hosts"
chmod 600 "$SSH_PATH/id_rsa"
eval $(ssh-agent)
ssh-add "$SSH_PATH/id_rsa"
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to TestFlight/PGY
run: |
cd ./ios && bundle exec fastlane beta
I tried to install new version(1.10.0) of cocopods(the same verion of my local Macbook Pro):
- name: Bundle install
run: cd ./ios && gem install cocoapods -v 1.10.0 && bundle install && bundle update fastlane
and tried to tweak the build type of xcode:
still not work.
Your build log shows the following error:
[05:32:01]: â–¸ ../../../hostedtoolcache/flutter/1.22.5-stable/x64/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
[05:32:01]: â–¸ const CustomScrollView({
[05:32:01]: â–¸ ^^^^^^^^^^^^^^^^
[05:32:01]: â–¸ Command PhaseScriptExecution failed with a nonzero exit code
[05:32:01]:
Could you check this? It might be possible that the error is not due to any xcode version.
I am working on Apollo Federation. So far, I have successfully deployed my services to google kubernetes cluster using travis.
The only remaining issue is, including the apollo service:push --serviceURL=http://auth-cluster-ip-service --serviceName=auth script in my CI/CD. But I have no idea how.. Its my first time setting up CI/CD.
My working travis config file without apollo service:push is:
sudo: required
services:
- docker
env:
global:
- SHA=$(git rev-parse HEAD)
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
language: node_js
node_js:
- 10
before_install:
- openssl aes-256-cbc -K $encrypted_9f3b5599b056_key -iv $encrypted_9f3b5599b056_iv -in service-account.json.enc -out service-account.json -d
- curl https://sdk.cloud.google.com | bash > /dev/null;
- source $HOME/google-cloud-sdk/path.bash.inc
- gcloud components update kubectl
- gcloud auth activate-service-account --key-file service-account.json
- gcloud config set project salading-production
- gcloud config set compute/zone asia-northeast3-a
- gcloud container clusters get-credentials salading-cluster
- echo "$SHA"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
script:
- echo "skipping tests"
deploy:
provider: script
script: bash ./deploy.sh
on:
branch: master
Below is the deploy.sh file:
docker build -t hoffnung8493/salading-auth:latest -t hoffnung8493/salading-auth:$SHA .
docker push hoffnung8493/salading-auth:latest
docker push hoffnung8493/salading-auth:$SHA
kubectl apply -f k8s
kubectl set image deployment/auth-deployment auth=hoffnung8493/salading-auth:$SHA
I tried adding two lines in deploy.sh:
npm i -g apollo
apollo service:push --serviceURL=http://auth-cluster-ip-service --serviceName=auth --endpoint=http://auth-cluster-ip-service
and got following errors:
Loading Apollo Project [started]
Loading Apollo Project [completed]
Uploading service to Apollo Graph Manager [started]
Fetching info from federated service
Uploading service to Apollo Graph Manager [failed]
→ request to http://auth-cluster-ip-service/ failed, reason: getaddrinfo ENOTFOUND auth-cluster-ip-service auth-cluster-ip-service:80
FetchError: request to http://auth-cluster-ip-service/ failed, reason: getaddrinfo ENOTFOUND auth-cluster-ip-service auth-cluster-ip-service:80
at ClientRequest.<anonymous> (~/.nvm/versions/node/v10.19.0/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1455:11)
Ok, while I was typing my own question in stackoverflow, I came up with the solution. Since, I already finished typing my question, I decided to share the solution.
It turns out an easy solution is simply adding 5 lines of code in after_deploy in .travis.yml file.
npm run dev &: this runs the node server in background
Afterwards sleep 3 gives the server some time to turn on.
Finally the last code pushes the new graphql schema to Apollo Graph Manager.
Note that in your travis-ci.com's settings, you have to add apollo's ENGINE_API_KEY as environment variable. Also note that your node server can print out some connection errors. In my case I did not provide, redis and mongodb connection related environment variables. But as long as the server itself is running for introspection, apollo service:push will work fine.
sudo: required
services:
- docker
env:
global:
- SHA=$(git rev-parse HEAD)
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
language: node_js
node_js:
- 10
before_install:
- openssl aes-256-cbc -K $encrypted_9f3b5599b056_key -iv $encrypted_9f3b5599b056_iv -in service-account.json.enc -out service-account.json -d
- curl https://sdk.cloud.google.com | bash > /dev/null;
- source $HOME/google-cloud-sdk/path.bash.inc
- gcloud components update kubectl
- gcloud auth activate-service-account --key-file service-account.json
- gcloud config set project salading-production
- gcloud config set compute/zone asia-northeast3-a
- gcloud container clusters get-credentials salading-cluster
- echo "$SHA"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
script:
- echo "skipping tests"
deploy:
provider: script
script: bash ./deploy.sh
on:
branch: master
after_deploy:
- npm install
- npm i -g apollo
- npm run dev &
- sleep 3
- apollo service:push --serviceURL=http://auth-cluster-ip-service --serviceName=auth --endpoint=http://localhost:3051
I am trying to setup bitbucket pipeline for a php based (Laravel-Lumen) app intended to be deployed on nanobox.io. I want this pipeline to deploy my app as soon as code changes are committed.
My bitbucket-pipelines.yml looks like this
image: php:7.1.29
pipelines:
branches:
staging:
- step:
name: Publish to staging version
deployment: staging
caches:
- composer
script:
- apt-get update && apt-get install -y unzip
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
# - vendor/bin/phpunit
- bash -c "$(curl -fsSL https://s3.amazonaws.com/tools.nanobox.io/bootstrap/ci.sh)"
- nanobox deploy
This gives Following error
+ nanobox deploy
Failed to validate provider - missing docker - exec: "docker": executable file not found in $PATH
Using nanobox with native requires tools that appear to not be available on your system.
docker
View these requirements at docs.nanobox.io/install
I then followed this page and changed second last line to look like this
sudo bash -c "$(curl -fsSL https://s3.amazonaws.com/tools.nanobox.io/bootstrap/ci.sh)"
when done that, I am getting following error
+ sudo bash -c "$(curl -fsSL https://s3.amazonaws.com/tools.nanobox.io/bootstrap/ci.sh)"
bash: sudo: command not found
I ran out of tricks here, also I don't have experience in this area. Any help is very much appreciated.
First, you can't use sudo in pipelines, but that's probably not relevant here. The issue is that nanobox cli wan't to execute docker, which isn't installed. You should enable the docker service for your step.
image: php:7.1.29
pipelines:
branches:
staging:
- step:
name: Publish to staging version
deployment: staging
# Enable docker service
services:
- docker
caches:
- composer
script:
- docker version
You might wan't to have a look at Pipelines docs as well: Run Docker commands in Bitbucket Pipelines
I am building my project on CircleCI and I have a build job that looks like this:
build:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- run:
name: Install pip
command: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && sudo python get-pip.py
- run:
name: Install AWS CLI
command: curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" && unzip awscli-bundle.zip && sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
- run:
name: Login to Docker Registry
command: aws ecr get-login --no-include-email --region us-east-1 | sh
- run:
name: Install Dep
command: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run:
name: Save Version Number
command: echo "export VERSION_NUM=${CIRCLE_TAG}.${CIRCLE_BUILD_NUM}" > deployment/dev/.env
- run:
name: Build App
command: source deployment/dev/.env && docker-compose -f deployment/dev/docker-compose.yml build
- run:
name: Test App
command: |
git config --global url."https://${GITHUB_PERSONAL_ACCESS_TOKEN} :x-oauth-basic#github.com/".insteadOf "https://github.com/"
dep ensure
go test -v ./...
- run:
name: Push Image
command: |
if [[ "${CIRCLE_TAG}" =~ ^v[0.9]+(\.[0-9]+)*-[a-z]*$ ]]; then
source deployment/dev/.env
docker-compose -f deployment/dev/docker-compose.yml push
else
echo 'No tag, not deploying'
fi
- persist_to_workspace:
root: .
paths:
- deployment/*
- tools/*
When I push a change to a branch, the build fails every time with Couldn't connect to Docker daemon at ... - is it running? when it reaches the Build App step of the build job.
Please help me figure out why branch builds are failing but tag builds are not.
I suspect you are hitting this docker-compose bug: https://github.com/docker/compose/issues/6050
The bug reports a misleading error (the one you're getting) when an image name in the docker-compose file is invalid.
If you use an environment variable for the image name or image tag, and that variable is set from a branch name, then it would fail on some branches, but not others.
The problem was occurring on the Save Version Number step. Sometimes that version would be .${CIRCLE_BUILD_NUM} since no tag was passed. Docker dislikes these tags starting with ., so I added a conditional check to see if CIRCLE_TAG was empty, and if it was, use some default version: v0.1.0-build.
I have successfully installed Gitlab CI and also linked it with my gitlab. I have also configured shared runners using docker with a ruby-2.2 image with mysql service.
Following was what I executed to configure a runner by referring https://about.gitlab.com/2015/04/17/unofficial-gitlab-ci-runner/:
$ gitlab-ci-multi-runner register \
--non-interactive \
--url "https://my.gitlab.ip/" \
--registration-token "REGISTRATION_TOKEN" \
--description "ruby-mysql" \
--executor "docker" \
--docker-image ruby:2.2 --docker-mysql latest
I have a sample Ruby / Rails application and for some reason the runner doesn't run the build. Here is my .gitlab-ci.yml:
image: ruby:2.2
services:
- mysql:latest
before_script:
- ruby -v
- gem install bundler
- cp config/database.yml.example config/database.yml
- cp config/secrets.yml.example config/secrets.yml
- bundle install
spec:
script:
- bundle exec rspec
tags:
- ruby-mysql
Try removing the first line image: ruby:2.2 of your .gitlab-ci.yml
I had a similar issue where the CI reported a success, yet didn't do any work.
I used the lint provided on http://my.domain/lint
It flagged "image" and "stage/stages" as not correct.
That's why I think removing the first line will help you.
I think the problem is that the community version doesn't recognize the keywords yet.