Jenkinsfile 2.14 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.'
}

Harald Sitter's avatar
Harald Sitter committed
19
cleanNode('master') {
20
  ws('/tmp/kde-os-autoinst') {
21 22 23 24
    try {
      stage('clone') {
        git 'https://github.com/apachelogger/kde-os-autoinst'
      }
25 26 27
      stage('rake-test') {
        sh 'rake test'
      }
28 29 30 31 32 33
      stage('iso-handover') {
          if (params.ISO) {
            echo 'Picking up ISO from trigger job.'
            sh "cp -v ${params.ISO} incoming.iso"
        }
      }
Harald Sitter's avatar
Harald Sitter committed
34
      stage('test_installation') {
Harald Sitter's avatar
Harald Sitter committed
35 36 37
        wrap([$class: 'LiveScreenshotBuildWrapper', fullscreenFilename: 'wok/qemuscreenshot/last.png']) {
          sh 'INSTALLATION=1 bin/contain.rb /workspace/bin/bootstrap.rb'
        }
38
      }
39 40 41 42 43 44
      stage('archive-raid') {
        tar = "/var/www/metadata/os-autoinst/${env.TYPE}.tar"
        sh "tar --exclude=*.iso --exclude=*.iso.* --exclude=*socket --exclude=wok/video.ogv --exclude=wok/ulogs --exclude=wok/testresults -cf ${tar}.new ."
        sh "gpg2 --armor --detach-sign -o ${tar}.new.sig ${tar}.new"
        sh "mv -v ${tar}.new ${tar}"
        sh "mv -v ${tar}.new.sig ${tar}.sig"
45 46
      }
    } finally {
Harald Sitter's avatar
Harald Sitter committed
47
      archiveArtifacts 'wok/testresults/*.png, wok/testresults/*.json, wok/ulogs/*, wok/video.ogv'
Harald Sitter's avatar
Harald Sitter committed
48
      junit 'junit/*'
Harald Sitter's avatar
Harald Sitter committed
49
      sh 'bin/contain.rb chown -R jenkins .'
50
    }
Harald Sitter's avatar
importy  
Harald Sitter committed
51 52 53 54 55 56 57 58 59 60 61
  }
}

def cleanNode(label = null, body) {
  node(label) {
    try {
      wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
        wrap([$class: 'TimestamperBuildWrapper']) {
          body()
        }
      }
Harald Sitter's avatar
Harald Sitter committed
62
    } finally {
63
      // step([$class: 'WsCleanup', cleanWhenFailure: true])
Harald Sitter's avatar
importy  
Harald Sitter committed
64 65 66
    }
  }
}
67 68 69 70 71 72 73 74 75 76 77 78 79 80

// 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
  }
  String[] types = ["useredition", "devedition-gitunstable", "devedition-gitstable"]
  for (type in types) {
    if (env.JOB_NAME.contains(type)) {
      return type
    }
  }
  return null
}