Docker Jenkins React Native Android持续集成

DockerFile

FROM jenkins/jenkins:2.122
MAINTAINER engineer <engineer@kezaihui.com>


USER root


# JAVA
RUN apt update
RUN apt-get install openjdk-8-jre -y
RUN ls /usr/lib/jvm/
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk-amd64


# 使用淘宝镜像安装Node.js v8.9.2
RUN wget https://npm.taobao.org/mirrors/node/v8.9.2/node-v8.9.2-linux-x64.tar.gz && \
    tar -C /usr/local --strip-components 1 -xzf node-v8.9.2-linux-x64.tar.gz && \
    rm node-v8.9.2-linux-x64.tar.gz

# install yarn
RUN npm install -g yarn react-native-cli && \
    yarn config set registry https://registry.npm.taobao.org --global && \
    yarn config set disturl https://npm.taobao.org/dist --global

# Install android sdk 
RUN mkdir -p opt/android/sdk \
    && chown -R jenkins.jenkins /opt/android/sdk \
    && cd opt/android/sdk/ \
    && curl https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -o android-sdk.zip && unzip android-sdk.zip -d . && rm android-sdk.zip \
    && yes | ./tools/bin/sdkmanager --licenses \
    && ./tools/bin/sdkmanager "tools" \
    && ./tools/bin/sdkmanager "build-tools;27.0.3" "build-tools;26.0.2" "build-tools;26.0.1" "build-tools;25.0.3" "build-tools;25.0.2" "build-tools;25.0.1" "build-tools;25.0.0" "build-tools;23.0.1" "platforms;android-27" "platforms;android-26" "platforms;android-25" "platforms;android-23" "extras;android;m2repository" "extras;google;m2repository" --no_https \
    && ./tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2" "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2" --no_https \
    && ./tools/bin/sdkmanager --list 


# Setup environment
ENV ANDROID_HOME /opt/android/sdk
ENV PATH ${PATH}:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools


RUN echo ANDROID_HOME="$ANDROID_HOME" >> /etc/environment
# drop back to the regular jenkins user - good practice
USER jenkins                                                 

sudo docker build -t jenkins .

docker run -d -p 8080:8080 jenkins

//找到container_id
docker run ps

sudo docker exec da52ddb0c3f9 cat /var/jenkins_home/secrets/initialAdminPassword

//运行docker bash
docker exec -it da52ddb0c3f9 /bin/bash
    原文作者:SheepYan9
    原文地址: https://www.jianshu.com/p/3110f7fc4626
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞