pipeline.groovy
branchstx-8.0.0
changeset 169 f9f519bb10b6
parent 129 b94e3e84adf9
child 178 7d15e6580ac0
equal deleted inserted replaced
168:37f3dd667f71 169:f9f519bb10b6
    19  * Supported configurations. To overwrite, do:
    19  * Supported configurations. To overwrite, do:
    20  *
    20  *
    21  *     ...
    21  *     ...
    22  *     pipeline = load "pipeline.groovy"
    22  *     pipeline = load "pipeline.groovy"
    23  *     ...
    23  *     ...
    24  *     pipeline.configurations = [ 'NODE': 'qnx', 'ARCH' : 'mips' ]
    24  *     pipeline.configurations = [ 'BUILD_TARGET': 'mips-sgi-irix' ]
    25  *     ...
    25  *     ...
    26  *
    26  *
    27  * Default value: see below.
    27  * Default value: see below.
    28  */
    28  */
    29 configurations = [
    29 configurations = [
    30     'NODE': ['windows' , 'linux' ],
    30     'BUILD_TARGET': ['i686-pc-mingw32' , 'x86_64-w64-mingw32', 'i686-pc-linux-gnu', 'x86_64-pc-linux-gnu' ]
    31     'ARCH': ['i386', 'x86_64' ]
       
    32 ]
    31 ]
    33 
    32 
    34 /** Branch to build. To overwrite do:
    33 /** Branch to build. To overwrite do:
    35  *
    34  *
    36  *     ...
    35  *     ...
    66  * "Default" pipeline:
    65  * "Default" pipeline:
    67  */
    66  */
    68 def build() {
    67 def build() {
    69     stage ( "Build" ) {
    68     stage ( "Build" ) {
    70         matrix ( configurations ) {
    69         matrix ( configurations ) {
    71             stage ( "Checkout - {${env.NODE}-${env.ARCH}} " ) {
    70             stage ( "Checkout - {${env.BUILD_TARGET}} " ) {
    72                 sshagent([ scm.getCredentialsId() ]) {
    71                 sshagent([ scm.getCredentialsId() ]) {
    73                     sh  """
    72                     sh  """
    74                         if [ -f Jenkinsfile.rb ]; then
    73                         if [ -f Jenkinsfile.rb ]; then
    75                             hg pull --ssh ssh ${scm.getSource()}
    74                             hg pull --ssh ssh ${scm.getSource()}
    76                         else
    75                         else
    77                             hg clone --ssh ssh ${scm.getSource()} .
    76                             hg clone --ssh ssh ${scm.getSource()} .
    78                         fi
    77                         fi
    79                         hg up ${branch != null ? branch : scm.getBranch()}
    78                         hg up ${branch != null ? branch : scm.getBranch()}
    80                         """
    79                         """
    81                     sh  "ruby Jenkinsfile.rb --project \"stx:jv-branch\" --arch ${env.ARCH}  update"
    80                     sh  "ruby Jenkinsfile.rb --project \"stx:jv-branch\" --build-target ${env.BUILD_TARGET} update"
    82                 }
    81                 }
    83             }
    82             }
    84 
    83 
    85             stage ( "Compile - {${env.NODE}-${env.ARCH}}") {
    84             stage ( "Compile - {${env.BUILD_TARGET}}") {
    86                 sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" compile"
    85                 sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" --build-target ${env.BUILD_TARGET} compile"
    87             }
    86             }
    88         }
    87         }
    89     }
    88     }
    90 
    89 
    91     stage ( "Test" ) {
    90     stage ( "Test" ) {
    92         matrix ( configurations ) {
    91         matrix ( configurations ) {
    93             stage ( "Test - {${env.NODE}-${env.ARCH}}") {
    92             stage ( "Test - {${env.BUILD_TARGET}}") {
    94                 /*
    93                 /*
    95                  * Some tests requires display, so:
    94                  * Some tests requires display, so:
    96                  *
    95                  *
    97                  *  * on *NIX hosts, launch Xvfb
    96                  *  * on *NIX hosts, launch Xvfb
    98                  *  * on Windows, do nothing. Windows slave must be configured
    97                  *  * on Windows, do nothing. Windows slave must be configured
    99                  *    so it has an access to interactive window station (which
    98                  *    so it has an access to interactive window station (which
   100                  *    means it has to run under user session, not as a service)
    99                  *    means it has to run under user session, not as a service)
   101                  */
   100                  */
   102                 if ( isUnix() ) {
   101                 if ( isUnix() ) {
   103                     wrap([$class: 'Xvfb', autoDisplayName: true, additionalOptions: '-screen 0 1024x768x24 -pixdepths 24 4 8 15 16 32', parallelBuild: true]) {
   102                     wrap([$class: 'Xvfb', autoDisplayName: true, additionalOptions: '-screen 0 1024x768x24 -pixdepths 24 4 8 15 16 32', parallelBuild: true]) {
   104                         sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" test"
   103                         sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" --build-target ${env.BUILD_TARGET} test"
   105                     }
   104                     }
   106                 } else {
   105                 } else {
   107                     sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" test"
   106                     sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" --build-target ${env.BUILD_TARGET} test"
   108                 }
   107                 }
   109                 junit allowEmptyResults: true, testResults: "reports/*build${env.BUILD_NUMBER}*.xml"
   108                 junit allowEmptyResults: true, testResults: "reports/*build${env.BUILD_NUMBER}*.xml"
   110             }
   109             }
   111         }
   110         }
   112     }
   111     }
   180     def combinations = combine(configurations).toArray()
   179     def combinations = combine(configurations).toArray()
   181     def branches = [failFast: true]
   180     def branches = [failFast: true]
   182     for (i = 0; i < combinations.length; i++) {
   181     for (i = 0; i < combinations.length; i++) {
   183         def index = i
   182         def index = i
   184         def conf = combinations[i];
   183         def conf = combinations[i];
   185         branches["${conf.NODE}-${conf.ARCH}"] = {
   184         branches["${conf.BUILD_TARGET}"] = {
   186             node ( conf.NODE ) {
   185             node ( conf.BUILD_TARGET ) {
   187                 def newEnv = []
   186                 def newEnv = []
   188                 for (k in conf.keySet()) {
   187                 for (k in conf.keySet()) {
   189                     newEnv.add("${k}=${conf[k]}")
   188                     newEnv.add("${k}=${conf[k]}")
   190                 }
   189                 }
   191                 withEnv ( newEnv ) {
   190                 withEnv ( newEnv ) {
   192                     ws ("workspace/${workspace}/${env.ARCH}") {
   191                     ws ("workspace/${workspace}/${env.BUILD_TARGET}") {
   193                         block()
   192                         block()
   194                     }
   193                     }
   195                 }
   194                 }
   196             }
   195             }
   197         }
   196         }
   211         def newEnv = []
   210         def newEnv = []
   212         for (k in conf.keySet()) {
   211         for (k in conf.keySet()) {
   213             newEnv.add("${k}=${conf[k]}")
   212             newEnv.add("${k}=${conf[k]}")
   214         }
   213         }
   215         withEnv ( newEnv ) {
   214         withEnv ( newEnv ) {
   216             ws ("workspace/${workspace}/${env.ARCH}") {
   215             ws ("workspace/${workspace}/${env.BUILD_TARGET}") {
   217                 block()
   216                 block()
   218             }
   217             }
   219         }
   218         }
   220     }
   219     }
   221 }
   220 }
   222 
   221 
   223 
   222 
   224 def artifacts() {
   223 def artifacts() {
   225     matrix ( configurations ) {
   224     matrix ( configurations ) {
   226         stage ( "Artifacts - {${env.NODE}-${env.ARCH}}") {
   225         stage ( "Artifacts - {${env.BUILD_TARGET}}") {
   227             sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" artifacts"
   226             sh "ruby Jenkinsfile.rb --project \"stx:jv-branch\" --build-target ${env.BUILD_TARGET} artifacts"
   228             archiveArtifacts artifacts: "artifacts/*build${env.BUILD_NUMBER}*.zip, artifacts/*build${env.BUILD_NUMBER}*.bz2, artifacts/*build${env.BUILD_NUMBER}*.sha256", fingerprint: true//, onlyIfSuccessful: true
   227             archiveArtifacts artifacts: "artifacts/*build${env.BUILD_NUMBER}*.zip, artifacts/*build${env.BUILD_NUMBER}*.bz2, artifacts/*build${env.BUILD_NUMBER}*.sha256", fingerprint: true//, onlyIfSuccessful: true
   229         }
   228         }
   230     }
   229     }
   231 }
   230 }
   232 
   231