Closed timozattol closed 9 years ago
Hi, the server is set up and you should be able to configure the scripts as you like. Let me know if you encounter any issues with it. (You should be able to see the job here).
Okay, what should we do to make it work ? (currently it fails) Should we generate an automatic build.xml ? How to make it automatically launch all the tests on master, and recognise the new tests when added ?
Thanks
We can set it up together during today's lab.
Essentially, yes, you should generate a build.xml; if you can get the tests running from command line on your own machines, you should be able to run the same commands on the Jenkins server.
We should follow this: https://sweng-forum.epfl.ch/t/setting-up-a-ci-environment/227
As mentionned, it would be cool if we started to follow proper git flow (https://guides.github.com/introduction/flow/index.html), for example using pull requests ! Jenkins is able to automatically test the pull requests before they're merged into master
Ask @JonasWagner to set up a build for you. You'll end up with a build job on jenkins, github hooks >configured in your repo and a build host you have ssh access to. Don't forget to tell him you want the >"full github package" with hooks.
@radubanabic can we have the ssh access to the server ? The first thing to do is run some commands on the server. Also how can I check if the github hook is well configured ?
We discussed with @radubanabic, evertything is okay.
Just a small question, how to make the script use the checkstyle ? Is it an "ant" option ?
Could @radubanabic or @philemonf help me ?
I tried to use the same script as what is given, and I don't understand something: we don't commit the .project and .classpath, so how is Jenkins supposed to know that a project is called "ProjectRadinAndroidApp" ? I mean, when each of us cloned the repo, they had to import the code and name the project (and the test project) how they wanted.
I tried to edit, then copy-paste the script into jenkins (just for testing purposes, I also have a scripts folder and everything), but as I thought it doesn't work
11:16:28 Error: The project either has no target set or the target is invalid. 11:16:28 Please provide a --target to the 'android update' command. 11:16:28 It seems that there are sub-projects. If you want to update them 11:16:28 please use the --subprojects parameter. 11:16:28 Error: Project folder 'tests' is not a valid directory.
Here's the script that I copy-pasted:
PROJECT_NAME=ProjectRadinAndroidApp
TEST_PROJECT=tests
export ANDROID_HOME=/home/jenkins/tools/android-sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export REPO_DIR=/home/jenkins/workspace/2014-sweng-team-project-radin
export SCRIPTS_DIR=$REPO_DIR/scripts
# Run android tests
ant_cmd="ant clean emma debug install test"
cd $REPO_DIR
android update project --path $PROJECT_NAME
android update test-project --path $TEST_PROJECT --main ../$PROJECT_NAME
cd $REPO_DIR/$TEST_PATH
# The following dirty hack is due to the fact that ant returns 0 EVEN IF TESTS FAIL
# But if something else goes wrong, then it returns 1
echo "Running $ant_cmd"
result=`$ant_cmd 2>&1 | tee /dev/stderr`
status="$?"
result=`echo "$result" | grep "FAIL"`
cd $REPO_DIR
if [ ! -z "$result" ] || [ ! "$status" -eq 0 ]; then
echo "Errors occured while testing android app"
exit 1
fi
exit 0
Here's the tree structure of the project:
├── ProjectRadinAndroidApp │ ├── AndroidManifest.xml │ ├── assets │ ├── bin │ ├── gen │ ├── ic_action_home.png │ ├── ic_launcher-web.png │ ├── libs │ ├── lint.xml │ ├── proguard-project.txt │ ├── project.properties │ ├── res │ ├── src │ └── tests ├── README.md └── scripts └── ci-job.sh
Thanks a lot for your help
It should be the same name as the folder (as it is), and the build.xml should tell git what to build and what to test. Did you re-generate the build.xml recently?
Mm I think one problem is that I never generated the build.xml ( :-1: to me) but I was under the impression the problem didn't come from that. (further in the console output, it says that no build.xml could be found, but I guess there is another problem before).
Right, I remember now why I did that, because in fact in HW1 it is explained that the build.xml is generated by the "android update project --path ...", what we are doing in the .sh script. So it should be generated on the jenkins server. Am I mistaking ?
Judging by the console, it seems that the update command is not executed properly. Two comments:
update test-project
command does not need a --target
argumentupdate
commands before calling ant
Done ! :)
Hello @radubanabic,
You said we could use a Jenkins server to do automated testing, do you think it's possible to set it up soon ? We have two "dummy tests" that work now, I suppose the server should be possible to take every class available in the test project and launch them ?
Should we set it up or should it be you ? Thanks in advance