David Caro has uploaded a new change for review. Change subject: First yaml job, the one checking teh yamls ......................................................................
First yaml job, the one checking teh yamls Change-Id: I0a48a2757bc241e2b8155c74de54bcc6335ee159 Signed-off-by: David Caro <[email protected]> --- A jobs/confs/shell-scripts/check_yaml.sh A jobs/confs/shell-scripts/htmldiff.sh A jobs/confs/yaml/defaults/defaults.yaml A jobs/confs/yaml/jobs/jenkins.yaml A jobs/confs/yaml/parmeters/gerrit.yaml A jobs/confs/yaml/parmeters/gerrit.yaml~ A jobs/confs/yaml/scms/jenkins.yaml 7 files changed, 231 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/jenkins refs/changes/23/28723/1 diff --git a/jobs/confs/shell-scripts/check_yaml.sh b/jobs/confs/shell-scripts/check_yaml.sh new file mode 100644 index 0000000..0f67890 --- /dev/null +++ b/jobs/confs/shell-scripts/check_yaml.sh @@ -0,0 +1,36 @@ +#!/bin/bash -e +## UPDATE JOBS FROM YAML +new_xmls_dir="$WORKSPACE/new_xmls" +old_xmls_dir="$WORKSPACE/old_xmls" +confs_dir="${WORKSPACE}/jenkins/jobs/confs/" +yaml_dir="${confs_dir}/yaml" +conf_file="${HOME}/.jenkinsjobsrc" +## cleanup +for dir in "$new_xmls_dir" "$old_xmls_dir"; do + [[ -d "$dir" ]] && rm -rf "$dir" + mkdir -p "$dir" +done +## Get new xmls +echo "Generating new xmls" +pushd "$confs_dir" +jenkins-jobs --conf "$conf_file" $options test -o "$new_xmls_dir" "$yaml_dir" +echo "########################" +## Get old xmls +echo "Generating previous xmls" +cd "$WORKSPACE/jenkins" +git fetch --all +git reset --hard origin/master +pushd "$confs_dir" +jenkins-jobs --conf "$conf_file" $options test -o "$old_xmls_dir" "$yaml_dir" +echo "########################" +## Get the diff +res=0 +diff -u "$old_xmls_dir" "$new_xmls_dir" \ +| "$WORKSPACE/jenkins/jobs/confs/shell-scripts/htmldiff.sh" \ +> "$WORKSPACE/differences.html" || res=1 +[[ $res -ne 0 ]] \ +|| { + echo "WARNING: #### XML CHANGED ####" + echo "Changed files:" + diff -q "$old_xmls_dir" "$new_xmls_dir" | awk '{ print $2 }' || : +} diff --git a/jobs/confs/shell-scripts/htmldiff.sh b/jobs/confs/shell-scripts/htmldiff.sh new file mode 100755 index 0000000..6b3598a --- /dev/null +++ b/jobs/confs/shell-scripts/htmldiff.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# +# Convert diff output to colorized HTML. + +cat <<XX +<html> +<head> +<title>Colorized Diff</title> +</head> +<style> +.diffdiv { border: solid 1px black; } +.comment { color: gray; } +.diff { color: #8A2BE2; } +.minus3 { color: blue; } +.plus3 { color: maroon; } +.at2 { color: lime; } +.plus { color: green; background: #E7E7E7; } +.minus { color: red; background: #D7D7D7; } +.only { color: purple; } +</style> +<body> +<pre> +XX + +echo -n '<span class="comment">' + +first=1 +diffseen=0 +lastonly=0 + +OIFS=$IFS +IFS=' +' + +# The -r option keeps the backslash from being an escape char. +read -r s + +while [[ $? -eq 0 ]] +do + # Get beginning of line to determine what type + # of diff line it is. + t1=${s:0:1} + t2=${s:0:2} + t3=${s:0:3} + t4=${s:0:4} + t7=${s:0:7} + + # Determine HTML class to use. + if [[ "$t7" == 'Only in' ]]; then + cls='only' + if [[ $diffseen -eq 0 ]]; then + diffseen=1 + echo -n '</span>' + else + if [[ $lastonly -eq 0 ]]; then + echo "</div>" + fi + fi + if [[ $lastonly -eq 0 ]]; then + echo "<div class='diffdiv'>" + fi + lastonly=1 + elif [[ "$t4" == 'diff' ]]; then + cls='diff' + if [[ $diffseen -eq 0 ]]; then + diffseen=1 + echo -n '</span>' + else + echo "</div>" + fi + echo "<div class='diffdiv'>" + lastonly=0 + elif [[ "$t3" == '+++' ]]; then + cls='plus3' + lastonly=0 + elif [[ "$t3" == '---' ]]; then + cls='minus3' + lastonly=0 + elif [[ "$t2" == '@@' ]]; then + cls='at2' + lastonly=0 + elif [[ "$t1" == '+' ]]; then + cls='plus' + lastonly=0 + elif [[ "$t1" == '-' ]]; then + cls='minus' + lastonly=0 + else + cls= + lastonly=0 + fi + + # Convert &, <, > to HTML entities. + s=$(sed -e 's/\&/\&/g' -e 's/</\</g' -e 's/>/\>/g' <<<"$s") + if [[ $first -eq 1 ]]; then + first=0 + else + echo + fi + + # Output the line. + if [[ "$cls" ]]; then + echo -n '<span class="'${cls}'">'${s}'</span>' + else + echo -n ${s} + fi + read -r s +done +IFS=$OIFS + +if [[ $diffseen -eq 0 && $onlyseen -eq 0 ]]; then + echo -n '</span>' +else + echo "</div>" +fi +echo + +cat <<XX +</pre> +</body> +</html> +XX diff --git a/jobs/confs/yaml/defaults/defaults.yaml b/jobs/confs/yaml/defaults/defaults.yaml new file mode 100644 index 0000000..ea1d0da --- /dev/null +++ b/jobs/confs/yaml/defaults/defaults.yaml @@ -0,0 +1,9 @@ +############################################################################## +#### Defaults +############################################################################### +- defaults: + name: global + project-type: freestyle + concurrent: false + logrotate: + numToKeep: 100 diff --git a/jobs/confs/yaml/jobs/jenkins.yaml b/jobs/confs/yaml/jobs/jenkins.yaml new file mode 100644 index 0000000..b85f9d7 --- /dev/null +++ b/jobs/confs/yaml/jobs/jenkins.yaml @@ -0,0 +1,26 @@ +- job: + name: jenkins_master_check-yaml_gerrit + node: master + parameters: + - gerrit_params: + branch: master + triggers: + - gerrit: + trigger-on-patchset-uploaded-event: true + escape-quotes: true + successful-message: 'You can check the diff in the job summary' + projects: + - project-compare-type: 'PLAIN' + project-pattern: 'jenkins' + branch-compare-type: 'PLAIN' + branch-pattern: 'master' + file-paths: + - compare-type: 'ANT' + pattern: 'jobs/yaml/**' + scm: + - jenkins-master-gerrit + builders: + - shell: !include-raw shell-scripts/check_yaml.sh + publishers: + - archive: + artifacts: '*.html' diff --git a/jobs/confs/yaml/parmeters/gerrit.yaml b/jobs/confs/yaml/parmeters/gerrit.yaml new file mode 100644 index 0000000..615dd08 --- /dev/null +++ b/jobs/confs/yaml/parmeters/gerrit.yaml @@ -0,0 +1,11 @@ +- parameter: + name: gerrit_params + parameters: + - string: + name: GERRIT_REFSPEC + default: 'refs/heads/{branch}' + description: 'Git refspec to build' + - string: + name: GERRIT_BRANCH + default: 'origin/{branch}' + description: 'Git branch to build' diff --git a/jobs/confs/yaml/parmeters/gerrit.yaml~ b/jobs/confs/yaml/parmeters/gerrit.yaml~ new file mode 100644 index 0000000..9f5040a --- /dev/null +++ b/jobs/confs/yaml/parmeters/gerrit.yaml~ @@ -0,0 +1,10 @@ +- parameter: + name: gerrit_params + - string: + name: GERRIT_REFSPEC + default: 'refs/heads/{branch}' + description: 'Git refspec to build' + - string: + name: GERRIT_BRANCH + default: 'origin/{branch}' + description: 'Git branch to build' diff --git a/jobs/confs/yaml/scms/jenkins.yaml b/jobs/confs/yaml/scms/jenkins.yaml new file mode 100644 index 0000000..5ba49d1 --- /dev/null +++ b/jobs/confs/yaml/scms/jenkins.yaml @@ -0,0 +1,17 @@ +############################################################################## +### SCM Definitions +############################################################################## +- scm: + name: jenkins-master-gerrit + scm: + - git: + url: git://gerrit.ovirt.org/jenkins.git + branches: + - $GERRIT_BRANCH + basedir: jenkins + scm-name: jenkins + name: '' + refspec: $GERRIT_REFSPEC + choosing-strategy: gerrit + clean: true + use-author: true -- To view, visit http://gerrit.ovirt.org/28723 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a48a2757bc241e2b8155c74de54bcc6335ee159 Gerrit-PatchSet: 1 Gerrit-Project: jenkins Gerrit-Branch: master Gerrit-Owner: David Caro <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
