Jenkinsfile.test 1.75 KB
Newer Older
1
env.DIST = 'bionic'
2 3
env.PWD_BIND = '/workspace'

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

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

19
if (env.TESTS_TO_RUN == null && env.PLASMA_DESKTOP == null && env.OPENQA_SNAP_NAME == null) {
20 21 22
  error 'TESTS_TO_RUN param not set. Cannot run nothing.'
}

23
fancyNode('openqa') {
24
  try {
25
    stage('clone') {
26
      checkout scm
27
    }
28 29 30
    stage('rake-test') {
      sh 'rake test'
    }
31 32
    stage('test') {
      wrap([$class: 'LiveScreenshotBuildWrapper', fullscreenFilename: 'wok/qemuscreenshot/last.png']) {
33
        sh 'bin/contain.rb /workspace/bin/bootstrap.rb'
34
      }
35 36
    }
  } finally {
37
    dir('metadata') { archiveArtifacts '*' }
38
    dir('wok') { archiveArtifacts allowEmptyArchive: true, artifacts: 'testresults/*, ulogs/*, video.*, vars.json, slide.html' }
39 40 41 42
    junit 'junit/*'
  }
}

43
def fancyNode(label = null, body) {
44
  node(label) {
45 46
    wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
      wrap([$class: 'TimestamperBuildWrapper']) {
47
        finally_cleanup { finally_chown { body() } }
48 49 50 51
      }
    }
  }
}
52

Harald Sitter's avatar
Harald Sitter committed
53 54 55 56 57 58 59
def finally_chown(body) {
  try {
    body()
  } finally {
    sh 'bin/contain.rb chown -R jenkins .'
  }
}
60

Harald Sitter's avatar
Harald Sitter committed
61
def finally_cleanup(body) {
62 63 64
  try {
    body()
  } finally {
65 66 67
    if (!env.NO_CLEAN) {
      cleanWs()
    }
68
  }
Harald Sitter's avatar
Harald Sitter committed
69
}
70

71 72 73 74 75
// 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
  }
Jonathan Riddell's avatar
Jonathan Riddell committed
76
  String[] types = ["user", "user_lts", "unstable", "testing"]
77 78 79 80 81 82 83
  for (type in types) {
    if (env.JOB_NAME.contains(type)) {
      return type
    }
  }
  return null
}