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

Added Dockerfile and Jenkinsfile for Android Browser #50

Merged
merged 1 commit into from May 9, 2018
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Added Dockerfile and Jenkinsfile for Android Browser
  • Loading branch information
Sharath Ganesh Pai
Sharath Ganesh Pai committed May 8, 2018
commit aec907d3f6006556a1a7d1894183309f765143bf
@@ -0,0 +1,14 @@
FROM node:8

RUN curl https://s3.amazonaws.com/cdncliqz/update/ghostery/moab/moab_8319dab > /bin/moab && \
chmod +x /bin/moab

ARG UID
ARG GID
RUN groupadd jenkins -g $GID \
&& useradd -ms /bin/bash jenkins -u $UID -g $GID

USER jenkins
COPY package.json /home/jenkins/
COPY package-lock.json /home/jenkins/
RUN cd /home/jenkins/ && npm install
@@ -0,0 +1,143 @@

properties([
parameters([
booleanParam(name: 'WITH_CLIQZ_MASTER', defaultValue: false, description: 'Builds with latest Cliqz master')
])
])

node('docker') {
stage ('Checkout') {
checkout scm
}

def img
def artifacts = []
def uploadPath = "cdncliqz/update/ghostery/${env.BRANCH_NAME}"

stage('Build Docker Image') {
img = docker.build('ghostery/build', '--build-arg UID=`id -u` --build-arg GID=`id -g` .')
// clean workdir
sh 'rm -rf build ghostery-*'
}

stage('Build Extension') {
img.inside() {
withCache {
sh 'rm -rf build'
if (params.WITH_CLIQZ_MASTER) {
sh 'npm install --save https://s3.amazonaws.com/cdncliqz/update/edge/ghostery/master/latest.tgz'
}
// make browser-core noisy
sh 'sed -i \'s/global.__DEV__/true/1\' node_modules/browser-core/build/core/console.js'
withGithubCredentials {
sh 'moab makezip'
}
// get the name of the firefox build
artifacts.add(sh(returnStdout: true, script: 'ls build/ | grep firefox').trim())
}
}
}

if (env.BRANCH_NAME != 'android_browser') {
stage('Package Chrome') {
withGithubCredentials {
def chromeArtifact = sh(returnStdout: true, script: 'ls build/ | grep chrome').trim().replace('.zip', '')
echo "${chromeArtifact}"
sh """#!/bin/bash -l
set -x
set -e
rm -rf ${chromeArtifact}/
mkdir -p ${chromeArtifact}
unzip build/${chromeArtifact}.zip -d ${chromeArtifact}
tools/crxmake.sh ${chromeArtifact}/ ~/.ssh/id_rsa
mv ${chromeArtifact}.crx build/
"""
artifacts.add("${chromeArtifact}.crx")
}
}
}

stage('Upload Builds') {
withS3Credentials {
echo "${env.BRANCH_NAME}/${env.BUILD_NUMBER}"
def uploadLocation = "s3://${uploadPath}/"
currentBuild.description = uploadLocation
artifacts.each {
sh "aws s3 cp build/${it} ${uploadLocation} --acl public-read"
}
}
}

if (env.BRANCH_NAME == 'develop') {
stage('Publish Beta') {
artifacts.each {
if (it.contains('firefox')) {
// firefox artifact (zip) - sign for cliqz_beta
def artifactUrl = "https://s3.amazonaws.com/${uploadPath}/${it}"
build job: 'addon-repack', parameters: [
string(name: 'XPI_URL', value: artifactUrl),
string(name: 'XPI_SIGN_CREDENTIALS', value: '41572f9c-06aa-46f0-9c3b-b7f4f78e9caa'),
string(name: 'XPI_SIGN_REPO_URL', value: 'git@github.com:cliqz/xpi-sign.git'),
string(name: 'CHANNEL', value: 'browser_beta')
]
} else if (it.contains('chrome')) {
withS3Credentials {
// publish chrome builds, also with 'latest' tag
def publishUrl = 's3://cdncliqz/update/ghostery_beta/chrome';
sh "aws s3 cp build/${it} ${publishUrl}/${it} --acl public-read"
sh "aws s3 cp build/${it} ${publishUrl}/latest.crx --acl public-read"
}
}
}
}
}
}

def withCache(Closure body=null) {
def cleanCache = {
sh 'rm -fr node_modules'
}

try {
cleanCache()
// Main dependencies
sh 'cp -fr /home/jenkins/node_modules .'

body()
} finally {
cleanCache()
}
}

def withGithubCredentials(Closure body) {
withCredentials([sshUserPrivateKey(
credentialsId: '6739a36f-0b19-4f4d-b6e4-b01d0bc2e175',
keyFileVariable: 'GHOSTERY_CI_SSH_KEY')
]) {
// initialise git+ssh access using ghostery-ci credentials
try {
sh '''#!/bin/bash -l
set -x
set -e
mkdir -p ~/.ssh
cp $GHOSTERY_CI_SSH_KEY ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
'''
body()
} finally {
sh 'rm -f ~/.ssh/id_rsa'
sh 'rm -f ~/.ssh/known_hosts'
}
}
}

def withS3Credentials(Closure body) {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: '06ec4a34-9d01-46df-9ff8-64c79eda8b14',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
usernameVariable: 'AWS_ACCESS_KEY_ID']]) {
body()
}
}
ProTip! Use n and p to navigate between commits in a pull request.