Dne 8.2.2018 v 20:08 Yesuraj Abraham napsal(a): > Hi, > > Is there a documentation which describes how to integrate Jenkins so that I > should be able to do > > 1. Triggering the test from Jenkins > > 2. View all the results in Jenkins > > > > For example, there are 3 machines that I would use > > 1. Remote DUT (where the test runs) > > 2. Linux host machine- which triggers the test using > --remote-hostname option. > > 3. A Jenkins server where Jenkins is installed > > > > I access the Jenkins via web interface, add Linux host machine as a node > and I can run the test. However I don’t know how to populate all the > results in Jenkins web interface >
Hello Yasuraj, we meant to write a simple howto: https://trello.com/c/9zTcfa0v/904-add-avocado-based-solution-for-jenkins-solutions-for-python but had no time to actually do it yet. If you are a blog-person, it'd be nice if you could take notes and create a guide :-) As for me I'm using Avocado and Avocado-vt via `jenkins-job-builder` using following templates: Parameter: ```yaml - parameter: name: avocado-run parameters: - node: name: NODE default-slaves: - "{machine}" allowed-multiselect: false ignore-offline-nodes: false description: "Use node you reserved in beaker!" - string: name: TESTS default: "{tests}" description: "List of space-separated tests" - string: name: EXTRA_PARAMS default: "{extra-params}" description: "Custom avocado params (eg. --vt-qemu-bin)" - string: name: GUEST_OS default: "{guest-os}" description: "Avocado-vt guest os" ``` Builder: ```yaml - builder: name: avocado-run builders: - shell: | #!/bin/bash rpm -q qemu-kvm-rhev || rpm -q qemu-kvm || rpm -q kvm echo -n "kernel-" uname -r - shell: | #!/bin/bash -x unset AUTOTEST_PATH avocado run $EXTRA_PARAMS --xunit "$WORKSPACE/results.xml" --job-results-dir "$WORKSPACE" --vt-guest-os "$GUEST_OS" --vt-arch "{guest-arch}" --vt-machine-type "{vt-machine}" -- $TESTS ERR=$? [ -f "$WORKSPACE/results.xml" ] || {{ echo "Result file not found, avocado exited with $ERR" ; exit -1; }} ``` Publisher: ```yaml - publisher: name: avocado-run publishers: - archive: artifacts: latest/**/* latest-only: false allow-empty: true - junit: results: results.xml - email-ext: recipients: "{mailto}" content-type: text body: | ${{PROJECT_NAME}} - Build #${{BUILD_NUMBER}} - ${{BUILD_STATUS}} Results: ${{BUILD_URL}}testReport/(root)/ $BUILD_LOG attach-build-log: false failure: false fixed: true improvement: true regression: true ``` But currently I'm slowly moving to pipeline, but the workflow is quite similar (only with pipeline I can merge the results from multiple jobs/machines and postprocess them before publishing). For triggers I'm using daily, weekly and triggered by external events via `curl`. In jjb it's quite simple to chain multiple jobs so my usual workflow is "provision_machine(s)->compile_qemu->trigger_several_jobs" plus I have some other jobs to recover in case of failure (eg. to try previous nightly build to get at least some coverage). One snippet to reboot machine after provisioning before running tests: ``` - job-template: name: "{name}-arm64-provision" builders: - shell: | # Update yum update -y # Update Avocado curl https://x.y.z/avocado-setup-internal.sh | sh -x # Make sure the node enables itself after reboot if [ ! -e "/usr/local/jenkins-enable-node.sh" ]; then # Add content of scripts/jenkins-enable-node.sh cat > /usr/local/bin/jenkins-enable-node.sh << \EOF #!/bin/bash curl -k https://$USER:[email protected]/computer/$(hostname)/api/json | grep -q '"temporarilyOffline":true' && curl -k https://$USER:[email protected]/computer/$(hostname)/toggleOffline --request 'POST' curl -k https://$USER:[email protected]/computer/$(hostname)/launchSlaveAgent --request 'POST' EOF chmod +x /usr/local/bin/jenkins-enable-node.sh fi grep -q "jenkins-enable-node.sh" /etc/crontab || echo "@reboot root /usr/local/bin/jenkins-enable-node.sh" >> /etc/crontab # Mark the node offline and reboot curl -k https://$USER:[email protected]/computer/$(hostname)/toggleOffline --request 'POST' --data offlineMessage="Rebooting after update" # Print some useful info: echo -e "---< SYSTEM >---" rpm -qa | grep -e qemu -e libvirt -e libguestfs -e kernel | sort avocado --version shutdown -r +1 publishers: - trigger-on: project: "{all-vt-machine-run-jobs}" condition: "SUCCESS" ``` For managing machines I use beaker controlled by script and I have machine profiles pre-defined on jenkins. Anyway I experimented with executing the nodes via jnlp which worked well as well but was not necessary in my case. I don't use `--remote-hostname` Avocado feature as Jenkins has quite rich ways to interact with target machines. Note that I'm not a real CI guy, this setup is for our small checks. I'm ccing our CI gurus, perhaps they'd be willing to share some tips and tricks. Regards, Lukáš
signature.asc
Description: OpenPGP digital signature
