Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devops 696 #104

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Docker/Dockerfile.jenkins
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Base image
FROM debian:bullseye

ARG ANDROID_API_LEVEL=34
ARG ANDROID_BUILD_TOOLS_LEVEL=34.0.0
ARG ANDROID_NDK_VERSION=25.2.9519653
ARG ANDROID_CLI_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip"
ARG SDKMANAGER_PACKAGES="build-tools;${ANDROID_BUILD_TOOLS_LEVEL} platforms;android-$ANDROID_API_LEVEL cmake;3.6.4111459 system-images;android-${ANDROID_API_LEVEL};google_apis;x86_64 platform-tools"

ARG USER_ID=1000
ARG USER_HOME=/home/usr
ARG GROUP_ID=1000
ARG KVM_GROUP_ID=999

ENV ANDROID_SDK_ROOT=$USER_HOME/android/sdk
ENV ANDROID_AVD_HOME=$USER_HOME/avds
# Deprecated: Still used by gradle, once gradle respects ANDROID_SDK_ROOT, this can be removed
ENV ANDROID_HOME=$ANDROID_SDK_ROOT
ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
ARG _SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager

ENV FLUTTER_VERSION=3.22.2


# Install necessary tools
RUN apt-get update && apt-get install -y \
curl \
git \
unzip \
xz-utils \
zip \
wget \
libglu1-mesa \
libsqlite3-dev \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*

RUN wget -q https://corretto.aws/downloads/latest/amazon-corretto-11-x64-linux-jdk.deb && \
apt-get update && \
apt-get install -y ./amazon-corretto-11-x64-linux-jdk.deb && \
rm amazon-corretto-11-x64-linux-jdk.deb

RUN if [ ! $(getent group $GROUP_ID) ]; then groupadd -g $GROUP_ID user; fi
RUN groupadd -g $KVM_GROUP_ID kvm
RUN useradd -m -u $USER_ID -g $GROUP_ID -G $KVM_GROUP_ID -d $USER_HOME -s /usr/sbin/nologin user
# Run all other commands as user
USER user

RUN mkdir -p $ANDROID_AVD_HOME

# Android SDK
# ------------------
#
ARG _CMD_LINE=$ANDROID_SDK_ROOT/cmdline-tools
RUN curl $ANDROID_CLI_TOOLS_URL --output /tmp/android_sdk.zip \
&& mkdir -p $ANDROID_SDK_ROOT \
&& unzip -d $ANDROID_SDK_ROOT /tmp/android_sdk.zip \
&& rm /tmp/android_sdk.zip \
&& mkdir -p $_CMD_LINE/latest \
&& mv $_CMD_LINE/bin $_CMD_LINE/lib $_CMD_LINE/source.properties $_CMD_LINE/latest/
# Installing SDK Packages
# -----------------------
#
#RUN if [ ! -z $SDKMANAGER_PACKAGES ]; then yes | $_SDKMANAGER $SDKMANAGER_PACKAGES; fi
RUN yes | $_SDKMANAGER $SDKMANAGER_PACKAGES
# Performance related settings for the JVM
# - Respect the cgroup settings for memory.
#
# Note: Usage of _JAVA_OPTIONS is in general discouraged.
# This is an internal flag that will be preferred over
# JAVA_TOOL_OPTIONS and the command line parameters.
# We still use it here to ensure that these settings
# are respected, no matter what is configured elsewhere.
# Accept SDK licenses
RUN yes | $_SDKMANAGER --licenses

# Install Flutter
RUN git clone https://github.com/flutter/flutter.git home/usr/local/flutter \
&& cd home \
&& cd usr \
&& cd local \
&& cd flutter \
&& git checkout $FLUTTER_VERSION \
&& /home/usr/local/flutter/bin/flutter doctor

# Add Flutter to PATH
ENV PATH="/home/usr/local/flutter/bin:${PATH}"

# Pre-cache Flutter dependencies
RUN flutter precache

WORKDIR /app

# Default command
CMD ["flutter", "--version"]
72 changes: 72 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
class DockerParameters {
// 'docker build' would normally copy the whole build-dir to the container, changing the
// docker build directory avoids that overhead
def dir = 'docker'
def args = ''
def label = 'LimitedEmulator'
def image = 'catrobat/pantroid-flutter:20241212'
}
def d = new DockerParameters()
pipeline {
agent {
docker {
image d.image
args d.args
label d.label
alwaysPull true
}
}

environment {
FLUTTER_HOME = '/home/usr/local/flutter'
ANDROID_HOME = '/home/usr/android/sdk'
PATH = "${env.FLUTTER_HOME}/bin:${env.PATH}"
}
stages {

stage('Checkout') {
steps {
sh """echo "Checking out the code..." """
checkout scm
}
}
stage('Dependencies') {
steps {
sh """ echo "Running flutter pub get..." """
sh 'flutter pub get'
sh 'flutter pub upgrade'
}
}
stage('Build') {
steps {
sh """ echo "Building the app..." """
sh 'flutter clean'
sh 'flutter build apk'
}
}
stage('Unit Tests') {
steps {
sh """echo "Running unit tests..." """
sh 'flutter test test/unit'
}
}
stage('UI Tests') {
steps {
sh """ echo "Running ui tests..." """
sh 'flutter test test/widget'
}
}
stage('Archive') {
steps {
sh """ echo "Archiving build artifacts..." """
archiveArtifacts artifacts: 'build/app/outputs/flutter-apk/app-release.apk', allowEmptyArchive: true
}
}
}
post {
always {
sh """echo "Cleaning up..." """
cleanWs()
}
}
}
Loading