Jenkinsfile 2.73 KB
Newer Older
Harald Sitter's avatar
importy  
Harald Sitter committed
1 2 3
env.DIST = 'xenial'
env.PWD_BIND = '/workspace'

4 5 6 7 8 9 10 11 12 13 14 15
if (env.TYPE == null) {
  if (params.TYPE != null) {
    env.TYPE = params.TYPE
  } else {
    type = inferType()
    if (type != null) {
      env.TYPE = type
    }
  }
}

if (env.TYPE == null) {
16 17 18
  error 'TYPE param not set. Cannot run install test without a type.'
}

19 20 21 22 23
if (env.OPENQA_SERIES == null) {
  env.OPENQA_SERIES = 'xenial'
}

// WARNING: these override the XML configs when run!
Harald Sitter's avatar
Harald Sitter committed
24
properties([
25
  disableConcurrentBuilds(),
Harald Sitter's avatar
Harald Sitter committed
26
  pipelineTriggers([upstream(threshold: 'UNSTABLE',
27
                             upstreamProjects: "iso_neon_${env.OPENQA_SERIES}_${TYPE}_amd64")]),
Harald Sitter's avatar
Harald Sitter committed
28 29 30
  pipelineTriggers([cron('0 H(9-22) * * *')])
])

31
lock(inversePrecedence: true, label: 'OPENQA_INSTALL', quantity: 1, variable: 'DEBUG_LOCK') {
32 33 34
  fancyNode('openqa') {
    try {
      stage('clone') {
35
        sh 'env'
36 37 38 39 40 41 42 43 44 45
        git 'git://anongit.kde.org/sysadmin/neon-openqa.git'
      }
      stage('rake-test') {
        sh 'rake test'
      }
      stage('iso-handover') {
          if (params.ISO) {
            echo 'Picking up ISO from trigger job.'
            sh "cp -v ${params.ISO} incoming.iso"
        }
46
      }
47

48 49
      stage('test_installation') {
        wrap([$class: 'LiveScreenshotBuildWrapper', fullscreenFilename: 'wok/qemuscreenshot/last.png']) {
50 51
          sh 'INSTALLATION=1 bin/contain.rb /workspace/bin/bootstrap.rb'
        }
52
      }
53 54 55 56
      if (env.ARCHIVE) {
        stage('archive-raid') {
          sh 'bin/archive.rb'
        }
57
      }
58
    } finally {
59
      dir('metadata') { archiveArtifacts allowEmptyArchive: true, artifacts: '*' }
60 61 62
      dir('wok') { archiveArtifacts allowEmptyArchive: true, artifacts: 'testresults/*, ulogs/*, video.*, vars.json, slide.html' }
      junit 'junit/*'
      sh 'bin/contain.rb chown -R jenkins .'
63 64 65
      // Make sure we fail if metadata was empty, we didn't assert this earlier
      // because we want the rest of the post-build to run.
      sh 'ls metadata/*'
66
    }
Harald Sitter's avatar
importy  
Harald Sitter committed
67 68 69
  }
}

70
def fancyNode(label = null, body) {
Harald Sitter's avatar
importy  
Harald Sitter committed
71
  node(label) {
72 73
    wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
      wrap([$class: 'TimestamperBuildWrapper']) {
74
        finally_cleanup { finally_chown { body() } }
Harald Sitter's avatar
importy  
Harald Sitter committed
75 76 77 78
      }
    }
  }
}
79

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
def finally_chown(body) {
  try {
    body()
  } finally {
    sh 'bin/contain.rb chown -R jenkins .'
  }
}

def finally_cleanup(body) {
  try {
    body()
  } finally {
    if (!env.NO_CLEAN) {
      cleanWs()
    }
  }
}

98 99 100 101 102
// When not called from an ISO build we'll want to infer the type from our own name.
def inferType() {
  if (!env.JOB_NAME) {
    return null
  }
Harald Sitter's avatar
Harald Sitter committed
103
  String[] types = ["useredition", "userltsedition", "devedition-gitunstable", "devedition-gitstable"]
104 105 106 107 108 109 110
  for (type in types) {
    if (env.JOB_NAME.contains(type)) {
      return type
    }
  }
  return null
}