Code Monkey home page Code Monkey logo

Comments (12)

thyrlian avatar thyrlian commented on May 17, 2024 1

Thank you @JaimeToca, have fun 😃

from androidsdk.

JaimeToca avatar JaimeToca commented on May 17, 2024

srry about the code style, github does not reformat well the pipeline.

from androidsdk.

thyrlian avatar thyrlian commented on May 17, 2024

Thank you, I appreciate the compliment.

Good to hear that it's working for you (except the Jenkins part). And don't worry about the code format, I've edited it, now it should be fine.

from androidsdk.

thyrlian avatar thyrlian commented on May 17, 2024

Unfortunately the error message is not too helpful :(

So we'll have to go through all kinds of possibilities which could go wrong:

  • The connection, it's done via SSH. But as you said, you don't have any particular configuration, in fact it's not needed, you just need to follow this section in README - either mount authorized_keys file from the host to a container, or build an image on your own, with a built-in authorized_keys which contains your id_rsa.pub (the one from Jenkins host). And by the way, since here the Jenkins master is talking with the agent (which is a container), so the host in this case would be the Jenkins master. However, according to the log, the task :presentation:test is already started, thus I would guess the SSH connection is working.
  • Mounting. I think you probably can try, define a custom gradle task, which is listing installed Android SDK packages. And run it in one of the stages in Jenkins pipeline, to see if the Android SDK is the barebone one, or the proper mounted one. Again, the volume from the host in your case would be your Jenkins master machine. So the path should be the absolute path on your Jenkins master.

BTW, instead of having pipeline file managing the creation of Docker container, maybe you can try the plugin approach. You can have a look at here.

from androidsdk.

JaimeToca avatar JaimeToca commented on May 17, 2024

Thanks a lot !

Indeed, SSH connection is working fine I tried different things changing the pipeline and it worked.
Also, I was doing some testing and I ran everything in my local machine (docker jenkins + docker android_vnc + unit tests) and apparently worked fine 😭 .

Regarding the SDK, when the URI exception happens the docker container is not stopped so from the "slave" node I did: docker exec -it id /bin/bash and checked the Android SDK was mounted properly. In any case, I'll list the installed packages with a gradle task and try the plugin 👍

I'm also comparing both console outputs (local and remote cases) to see if I find something.

Here is some more output from the deploy phase ( the only thing before this is the pull from the repo)

docker build -t c6dcdc602f4be0ba5e5e84a895f5bd380eba8a4b -f ci/Dockerfile ci
Sending build context to Docker daemon 10.75 kB

Step 1/23 : FROM ubuntu:16.04
 ---> b0ef3016420a
Step 2/23 : LABEL maintainer = "[email protected]"
 ---> Using cache
 ---> 659b5ea6a2cc
Step 3/23 : RUN dpkg --add-architecture i386 && apt-get update -y && apt-get install -y libncurses5:i386 libc6:i386 libstdc++6:i386 lib32gcc1 lib32ncurses5 lib32z1 zlib1g:i386 && apt-get install -y --no-install-recommends openjdk-8-jdk && apt-get install -y git wget zip && apt-get install -y qt5-default
 ---> Using cache
 ---> 2828d4a46678
Step 4/23 : ARG GRADLE_VERSION=4.10.3
 ---> Using cache
 ---> d6d1371aa8ab
Step 5/23 : RUN cd /opt && wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip && unzip gradle*.zip && ls -d */ | sed 's/\/*$//g' | xargs -I{} mv {} gradle && rm gradle*.zip
 ---> Using cache
 ---> 10838529f722
Step 6/23 : ARG KOTLIN_VERSION=1.3.11
 ---> Using cache
 ---> 0e191f2ab6f3
Step 7/23 : RUN cd /opt && wget -q https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip && unzip *kotlin*.zip && rm *kotlin*.zip
 ---> Using cache
 ---> 08377f19afcf
Step 8/23 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
 ---> Using cache
 ---> 7addb04905c0
Step 9/23 : ENV GRADLE_HOME /opt/gradle
 ---> Using cache
 ---> 8db99940a477
Step 10/23 : ENV KOTLIN_HOME /opt/kotlinc
 ---> Using cache
 ---> f67a88b10b4a
Step 11/23 : ENV ANDROID_HOME /opt/android-sdk
 ---> Using cache
 ---> e05b63361907
Step 12/23 : ENV PATH ${PATH}:${GRADLE_HOME}/bin:${KOTLIN_HOME}/bin:${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools/bin
 ---> Using cache
 ---> 1e9bb0ba0fe5
Step 13/23 : ENV _JAVA_OPTIONS -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
 ---> Using cache
 ---> 15edfb288d12
Step 14/23 : ENV GRADLE_OPTS -Dfile.encoding=utf-8
 ---> Using cache
 ---> b62a04901d12
Step 15/23 : EXPOSE 5037
 ---> Using cache
 ---> 1dcd8e2aac41
Step 16/23 : ENV USER root
 ---> Using cache
 ---> 0e470fdeb581
Step 17/23 : ENV DISPLAY :1
 ---> Using cache
 ---> 9321f4269827
Step 18/23 : EXPOSE 5901
 ---> Using cache
 ---> f0e982be7531
Step 19/23 : ADD vncpass.sh /tmp/
 ---> Using cache
 ---> 82ad7b2040ed
Step 20/23 : ADD watchdog.sh /usr/local/bin/
 ---> Using cache
 ---> ba3ccd767418
Step 21/23 : ADD supervisord_vncserver.conf /etc/supervisor/conf.d/
 ---> Using cache
 ---> febfde181178
Step 22/23 : RUN apt-get update -y &&     apt-get install -y --no-install-recommends xfce4 xfce4-goodies xfonts-base tightvncserver expect &&     chmod +x /tmp/vncpass.sh; sync &&     /tmp/vncpass.sh &&     rm /tmp/vncpass.sh &&     apt-get remove -y expect && apt-get autoremove -y
 ---> Using cache
 ---> ee17257a5d09
Step 23/23 : WORKDIR /android-app
 ---> Using cache
 ---> 4c91ebedca79
Successfully built 4c91ebedca79
[Pipeline] dockerFingerprintFrom
 > git rev-parse origin/dockerCI^{commit} # timeout=10
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 10175b1d76746adbdef85289ab0ae98ba59448b4
 > git rev-list --no-walk 56ca9e1f68f710ba57cc380558d6c836522061e7 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] sh
+ docker inspect -f . c6dcdc602f4be0ba5e5e84a895f5bd380eba8a4b
.
[Pipeline] withDockerContainer
slave does not seem to be running inside a container
$ docker run -t -d -u 1001:1001 --privileged -v /home/jaime/Android/Sdk:/opt/android-sdk -w /home/jaime/Desktop/example/workspace/my_jenkins_job -v /home/jaime/Desktop/example/workspace/my_jenkins_job:/home/jaime/Desktop/example/workspace/my_jenkins_job:rw,z -v /home/jaime/Desktop/example/workspace/my_jenkins_job@tmp:/home/jaime/Desktop/example/workspace/my_jenkins_job@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** c6dcdc602f4be0ba5e5e84a895f5bd380eba8a4b cat
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Presentation unit tests)
[Pipeline] echo
Running presentation tests
[Pipeline] sh
$ docker top ad0f4df14f5ca01ad1c87ee124e3e453db2b6a3cb3aad04f608080e0ab3f4007 -eo pid,comm
+ ./gradlew --daemon clean :presentation:test
Picked up _JAVA_OPTIONS: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
Downloading https://services.gradle.org/distributions/gradle-4.6-all.zip
.........

Unzipping /home/jaime/Desktop/example/workspace/my_jenkins_job/?/.gradle/wrapper/dists/gradle-4.6-all/bcst21l2brirad8k2ben1letg/gradle-4.6-all.zip to /home/jaime/Desktop/example/workspace/my_jenkins_job/?/.gradle/wrapper/dists/gradle-4.6-all/bcst21l2brirad8k2ben1letg
Set executable permissions for: /home/jaime/Desktop/example/workspace/my_jenkins_job/?/.gradle/wrapper/dists/gradle-4.6-all/bcst21l2brirad8k2ben1letg/gradle-4.6/bin/gradle
Starting a Gradle Daemon (subsequent builds will be faster)

Now dependencies are downloaded (nothing strange seems to happen), however I saw a message that did not show up when I ran everything in local . This might be the cause?

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 11.4.2 will be used.
please apply google-services plugin at the bottom of the build file.
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]

I'll keep you updated.

Thanks again,
Cheers

from androidsdk.

thyrlian avatar thyrlian commented on May 17, 2024

Hola!

So you're saying, apart from failing with the same error like before. Now after comparing logs between host and remote, you found remote has this strange info google-services plugin could not detect any version...?

That's weird. Clean environment, no code difference. This sounds more like gradle dependencies difference. But I believe that you're using same code, so that should not happen at all.

from androidsdk.

thyrlian avatar thyrlian commented on May 17, 2024

I just noticed that you mounted your code / workspace (in directory) to container:

docker run -t -d -u 1001:1001 --privileged -v /home/jaime/Android/Sdk:/opt/android-sdk -w /home/jaime/Desktop/example/workspace/my_jenkins_job -v /home/jaime/Desktop/example/workspace/my_jenkins_job:/home/jaime/Desktop/example/workspace/my_jenkins_job:rw,z -v /home/jaime/Desktop/example/workspace/my_jenkins_job@tmp:/home/jaime/Desktop/example/workspace/my_jenkins_job@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** c6dcdc602f4be0ba5e5e84a895f5bd380eba8a4b cat

It can't guarantee the same code. Could you please try to git checkout your code from a remote repo, which doesn't have any binary or cache inside, but only your code.

But from the other hand, you've tried many times, and if the results are the same, I don't think it's really caused by code. Still, let's make sure it's consistent and clean. Thanks.

from androidsdk.

JaimeToca avatar JaimeToca commented on May 17, 2024

Yes. it seems that the "dockerfile" declarative from the pipeline mounts the code / workspace to container automatically. I think its a good point, I'll try to do a clean check out from the repo and deploy the docker image manually either using "sh" declarative or bash script. I'm not trusting "dockerfile" anymore lol. it might be the problem.

Thanks Thyrlian,
Cheers

from androidsdk.

thyrlian avatar thyrlian commented on May 17, 2024

Great. Thanks to share your findings.

Again, maybe you wanna also give a try of this approach.

from androidsdk.

JaimeToca avatar JaimeToca commented on May 17, 2024

Hey thyrlian, problem fixed :). Unit test are running 💃

  1. Clean checkout
  2. Avoid dockerfile declarative and used instead:
        stage('Deploying docker'){
         steps{
          echo 'Setting up docker'
          sh 'docker run -d --name=${BUILD_NUMBER} -v /home/jaime/Android/Sdk:/opt/android-sdk -v /mydir:/app -w /app thyrlian/android-sdk-vnc'
          }
        }
  1. Used docker exec ${BUILD_NUMBER} ./gradlew :presentation:test . Maybe SSH could be a valid option as well.

Just one question, in case I want to work with the VNC desktop I map the port with -p 5901:5901 . First time I deployed worked fine, after that I get this message.

"Error starting userland proxy: listen tcp 0.0.0.0:5901: bind: address already in use."

Do I need to clean up something? am i missing something? 😌

Thanks,
Cheers

P.S: I'm checking out you approach ;)

from androidsdk.

thyrlian avatar thyrlian commented on May 17, 2024

Interesting. So agent.dockerfile does make a difference than stage.steps. Don't know why.

In terms of cleaning up - the occupied ports. You can try this after each run (when you've finished working):

docker stop ${BUILD_NUMBER} &> /dev/null && docker rm ${BUILD_NUMBER} &> /dev/null

from androidsdk.

JaimeToca avatar JaimeToca commented on May 17, 2024

Thanks thyrlian ;)

Cheers

P.S: I think you can close this thread !

from androidsdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.