Skip to content
Snippets Groups Projects
Commit 6bb5f660 authored by Norman Stetter's avatar Norman Stetter
Browse files

Add gitlab CI

* Add a pipeline that runs a yocto build:
  * setup the executor with ssh keys and install repo tool
  * checkout the manifest and get the layers
  * update the meta-guf layer that triggered the pipeline to the
  triggering commit
  * run a yocto build
  * copy build artifacts to the artifacts dir on the host
parent 70e49cb7
No related branches found
No related tags found
1 merge request!25Add gitlab CI
image:
name: "crops/poky:ubuntu-20.04"
# Override entrypoint so we can pass --id to set the UID and GID for the user that is created in the container.
# This is a feature of the crops/poky images. See poky-entry.py for details.
entrypoint: ["/usr/bin/distro-entry.sh", "/usr/bin/dumb-init", "--", "/usr/bin/poky-entry.py", "--id=118:998"]
stages:
- prepare
- build
- deploy
variables:
GIT_STRATEGY: none
MANIFEST_URL: "git@gitlab.com:garz-fricke/yocto/manifest.git"
REPODIR: ${CI_PROJECT_DIR}/.repo
.setup_ssh: &setup_ssh
# setup ssh key to access private repos, see https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor
- eval $(ssh-agent -s)
- echo "$JENKINSGUF_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# add content of variable SSH_KNOWN_HOSTS to known hosts, see https://docs.gitlab.com/ee/ci/ssh_keys/#verifying-the-ssh-host-keys
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
.repo_install: &repo_install
# install repo tool
- cd ~
- wget "https://raw.githubusercontent.com/GerritCodeReview/git-repo/v2.8/repo"
- chmod a+x repo
.repo_checkout: &repo_checkout
# setup build dir
- cd ${CI_PROJECT_DIR}
- ~/repo init -u ${MANIFEST_URL} -b ${CI_DEFAULT_BRANCH}
- ~/repo sync --force-sync
.checkout_commit: &checkout_commit
# checkout the commit that triggered the pipeline
- cd ${CI_PROJECT_DIR}/sources/${CI_PROJECT_NAME}
- git fetch origin
- git checkout ${CI_COMMIT_SHA}
.repo_tag: &repo_tag
# create a manifest containing all fixed revisions
- ~/repo manifest -r > ${REPODIR}/manifests/default.xml.tagged
prepare_environment:
tags:
- builds
stage: prepare
before_script:
- *setup_ssh
script:
- *repo_install
- *repo_checkout
- *checkout_commit
- *repo_tag
artifacts:
expire_in: 3h
paths:
- "*"
cache:
untracked: false
key:
files:
- .repo/manifests/default.xml
prefix: layers
paths:
- "sources/*/{[^.git]}*/*"
.build:
tags:
- builds
stage: build
variables:
SETUPSCRIPT: "setup-environment"
IMAGEPATH: "tmp/deploy/images"
INSTALLSCRIPT: "fng-install.sh"
before_script:
- *setup_ssh
script:
# setup build environment
- export MACHINE="${CI_PARAM_MACHINE}"
- export DISTRO="${CI_PARAM_DISTRO}"
- source ./"${SETUPSCRIPT}" build
# start build
- echo -e "section_start:`date +%s`:bitbake_run\r\e[0KBitbake Log"
- bitbake "${CI_PARAM_IMAGE}"
- echo -e "section_end:`date +%s`:bitbake_run\r\e[0K"
# print install instructions
- |-
if [[ -f "${IMAGEPATH}/${CI_PARAM_MACHINE}/${INSTALLSCRIPT}" ]]; then
echo -e "Install the image:"
echo -e "export TFTP=\"${CI_SERVER_URL}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts/raw/build/tmp/deploy/images/${CI_PARAM_MACHINE}\""
echo -e "curl \$TFTP/${INSTALLSCRIPT} | sh"
fi
parallel:
matrix:
- CI_PARAM_MACHINE: [imx6guf]
CI_PARAM_DISTRO: [guf-wayland]
CI_PARAM_IMAGE: [guf-image]
artifacts:
paths:
- "build/tmp/deploy/images/**/*"
deploy_local:
tags:
- builds
stage: deploy
variables:
GIT_STRATEGY: none
script:
- mkdir -p /artifacts/${CI_PIPELINE_ID}/
- ls -al ${CI_PROJECT_DIR}
- cp -a build/tmp/deploy/images/* /artifacts/${CI_PIPELINE_ID}/
- echo -e "Artifacts are stored at http://${CI_RUNNER_DESCRIPTION##builds@}/gitlab_artifacts/${CI_PIPELINE_ID}/"
include:
- local: '.gitlab-ci-template.yml'
# use the .build template and specify which MACHINE/IMAGE/DISTO matrix to build
build:
extends: .build
parallel:
matrix:
- CI_PARAM_MACHINE: [imx6guf]
CI_PARAM_DISTRO: [guf-wayland]
CI_PARAM_IMAGE: [guf-image]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment