The image at the docker hub, ichinosebinit/jenkins-flutter-android:latest
has installed Android SDK, flutter and an image of an Android OS.
-
The jenkins image is pulled and flutter is installed.
-
The Flutter bin folder is setup in the path.
-
The default jdk is installed.
-
Android SDK is fetched and unzipped.
-
The contents of the Android SDK is managed,
moved to a directory
to be used by the Jenkins. -
The licenses are accepted using the SDK manager.
-
The Android OS image is downloaded using the SDK manager.
-
The docker file is given here Docker File for Image creation.
docker pull ichinosebinit/jenkins-flutter-android:latest
docker run -p 8070:8080 -v /D:/data:/var/jenkins_home ichinosebinit/jenkins-flutter-android:latest
Here, you can replace the port number i.e. 8070 to any one which is not allocated. But do not change the latter port number. The -v option refers to the mounted directory with the host and the container. Mount the preferred directory to the left side before ":" and leave the right mounted directories unchanged.
Open your web browser and open http://localhost:8070/
. Setup the Jenkins with admin password password given in log as initial password
and install the necessary plugins.
- Browse over to
Manage Jenkins
and go toManage Plugins
page. On the Available tab, search forGitLab plugin
andAndroid Signing Plugin
and install those plugins.
- Go back to
Manage Jenkins
, head over toManage Credentials
under theSecurity
section. - Under the
Stores scoped to Jenkins
section, click onJenkins
under theStore
tab. - Select the
Global credentials (unrestricted)
and selectAdd Credentials
in the left section of the page.
- Select the
GitLab API Token
option under theKind
field. - Select the
Global
option under theScope
. - Paste the
API Token
from the GitLab of your account. - You can get your
API Token
from Gitlab Documentation - Give an unique
ID
for the Token. - Give a description for the Token.
- Select the
Username with password
option under theKind
field. - Select the
Global
option under theScope
. - Enter your
Username
of your GitLab account. - Enter your
Password
of your GitLab account. - Give an unique
ID
for the account. - Give a description for the account.
Note: The Id given here is used in the Jenkins pipeline script. So remember it or copy the ID for future use.
- Select the
Certificate
option under theKind
field. - Select the
Global
option under theScope
. - Check the
Upload PKCS#12 certificate
radio button. - Select the
file
used for signing the APK. - Press the
Change Password
button. - Enter the
password used while creating the certificate
. - Give an unique
ID
for the account. - Give a description for the account.
Note: The Id given here is used in the Jenkins pipeline script. So remember it or copy the ID for future use.
- Browse over to
Manage Jenkins
and go toConfigure System
page. - Head down and Check the
Environment Variables
checkbox under the headingGlobal Properties
. - Click the
Add
button. - Add
ANDROID_HOME
asName
and/android-sdk
asValue
. - Click the
Add
button again. - Add
HOME
asName
and/root
asValue
. - Click the
Apply
button
- Head down on the same page and under the heading
Gitlab
check theEnable authentication for '/project' end-point
checkbox. - Enter the
Connection Name
. - Enter
https://gitlab.com
asGitlab host URL
. - Select the ID of the
GitLab Connection using API Token
previously saved in credentials. - Press the
Test Connection
button. - In case of
Success
, press theSave
button. Else, check forpermissions
in your repository.
- Copy and paste the script from the Jenkinsfile in your editor.
- In the
stage git
, change thebranch
name,credentialsId
previously setup andurl
. - In the
stage sign Android
, change thekeyStoreId
previously setup in credentials. - Use the contents of the file in the next step.
- Select
New Item
and selectPipeline
- Enter the name for your project. Avoid spaces if you can as it may lead to errors while mapping directories. The name for the project would be used later again.
- Check the
Discard old builds
and enter 3 inMax # of builds to keep
. - Under the
GitLab Connection
, select theConnection Name
previously created. - Under the
Build Triggers
, select theBuild when a change is pushed to GitLab. GitLab webhook
checkbox. - Check the
Poll SCM
checkbox and enter* * * * *
in theSchedule
field. - Under the
Pipeline
section, copy and paste the jenkins script edited previously. - Press the
Apply
andSave
button.
- Browse the newly created
job/item
. - Click the
Build Now
option. - Wait for the
Build to finish
.
docker pull nginx:alpine
- The directory previously mounted needs to be given as the path.
- Open the previously mounted directory path. Open workspace and then the project that was created.
- Copy the path for the opened directory. e.g.
/D:/data/workspace/easyshop/
- Append the path
build/app/outputs/flutter-apk
with the previous path. e.g./D:/data/workspace/easyshop/build/app/outputs/flutter-apk
- Use the path in the left side of ":" in -v option.
docker run -p 8060:80 -v "path":/usr/share/nginx/html nginx:alpine
- Copy the web folder from the repository with index file, css and images directory.
- Paste the contents of the web folder in the mounted directory in the host machine.
- The path for the directory would be the path given while mounting.
- Open the browser and browse
http:localhost:8060
.