Snippets

fahl-design Jenkinsfile Template

Created by fahl-design last modified
node {
    try {
        notifyBuild('STARTED')

        stage('Prepare code') {
            gitCheckThatOut('branch', 'repo URL')
        }

        stage('Testing') {
            echo 'Testing'
            echo 'Testing - publish coverage results'
        }

        stage('Staging') {
            echo 'Deploy Stage'
        }
        // @todo add checkpoint
        stage('Deploy') {
            echo 'Deploy - Backend'
            echo 'Deploy - Frontend'
        }
  } catch (e) {
    // If there was an exception thrown, the build failed
    currentBuild.result = "FAILED"
    throw e
  } finally {
    // Success or failure, always send notifications
    notifyBuild(currentBuild.result)
  }
}


/**
 * Clean a Git project workspace.
 * Uses 'git clean' if there is a repository found.
 * Uses Pipeline 'deleteDir()' function if no .git directory is found.
 */
def gitClean() {
    timeout(time: 60, unit: 'SECONDS') {
        if (fileExists('.git')) {
            echo 'Found Git repository: using Git to clean the tree.'
            // The sequence of reset --hard and clean -fdx first
            // in the root and then using submodule foreach
            // is based on how the Jenkins Git SCM clean before checkout
            // feature works.
            sh 'git reset --hard'
            // Note: -e is necessary to exclude the temp directory
            // .jenkins-XXXXX in the workspace where Pipeline puts the
            // batch file for the 'bat' command.
            //sh 'git clean -fd -e "src/vendor/"'
            //sh 'git submodule foreach --recursive git reset --hard'
            //sh 'git submodule foreach --recursive git clean -ffdx'
        }
        else
        {
            echo 'No Git repository found: using deleteDir() to wipe clean'
            deleteDir()
        }
    }
}

def notifyBuild(String buildStatus = 'STARTED') {
  // build status of null means successful
  buildStatus =  buildStatus ?: 'SUCCESSFUL'

  // Default values
  def colorName = 'RED'
  def colorCode = '#FF0000'
  def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
  def summary = "${subject} (${env.BUILD_URL})"
  def details = """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
    <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>"""

  // Override default values based on build status
  if (buildStatus == 'STARTED') {
    color = 'YELLOW'
    colorCode = '#FFFF00'
  } else if (buildStatus == 'SUCCESSFUL') {
    color = 'GREEN'
    colorCode = '#00FF00'
  } else {
    color = 'RED'
    colorCode = '#FF0000'
  }

  // Send notifications
  slackSend (color: colorCode, message: summary)

  emailext(
      subject: subject,
      body: details,
      recipientProviders: [[$class: 'DevelopersRecipientProvider']]
    )
}

def gitCheckThatOut(String branch, String vcsUrl) {
    branch =  branch ?: 'master'
    // cleanup
    gitClean()
    // checkout
    git branch: "${branch}", url: "${vcsUrl}"
    // get last tag
    sh "git describe --abbrev=0 --tags > .git/tagName"
    tagName = readFile('.git/tagName')
    echo "${tagName}"
    // set DisplayName
    currentBuild.displayName = tagName
}

Comments (1)

  1. uzanti hesap

    O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O. O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O. O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O .O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O. O.O.O.O.O.O.O.O.O rssfeeds.usatoday.com/~/t/0/0/mmajunkie/~https:/agariogame.net/www.researchgate.net/deref/http://agariogame.nethobby.idnes.cz/peruanske-palive-papricky-rocoto-dlz-/redir.aspx?url=http%3A%2F%2Fagariogame.netoptimize.viglink.com/page/pmv?url=https://agariogame.nettrello.com/add-card?source=mode=popup&name=click%2Bhere&desc=http%3A%2F%2Fagariogame.netsound2sense.archiveweb.mus.cam.ac.uk/?URL=agariogame.netfeeds.businessinsider.com.au/~/t/0/0/businessinsideraustralia/~https:/agariogame.net/www.astro.wisc.edu/?URL=https%3A%2F%2Fagariogame.netimages.google.com/url?sa=t&url=https%3A%2F%2Fagariogame.netm.odnoklassniki.ru/dk?st.cmd=outLinkWarning&st.rfn=https%3A%2F%2Fagariogame.net%2Fwww.jobzone.ny.gov/views/jobzone/leaving_site.jsf?id=304&url=https%3A%2F%2Fagariogame.nettvtropes.org/pmwiki/no_outbounds.php?o=https%3A%2F%2Fagariogame.net%2Frssfeeds.freep.com/~/t/0/_/freep/home/~/https:/agariogame.net/community.acer.com/en/home/leaving/agariogame.netredirects.tradedoubler.com/utm/td_redirect.php?td_keep_old_utm_value=1&tduid=991a03343b6089cca9cbe799f011b89c&url=https%3A%2F%2Fagariogame.netfcaw.library.umass.edu/goto/https:/agariogame.net/guru.sanook.com/?URL=https%3A%2F%2Fagariogame.net%2Fblog.ss-blog.jp/_pages/mobile/step/index?u=https://agariogame.netold.post-gazette.com/pets/redir.asp?url=https%3A%2F%2Fagariogame.net%2Faccounts.cancer.org/login?redirectURL=https://agariogame.netwww.fhwa.dot.gov/reauthorization/reauexit.cfm?link=https%3A%2F%2Fagariogame.netsitereport.netcraft.com/?URL=https%3A%2F%2Fagariogame.net%2Fgo.onelink.me/v1xd?pid=Patch&c=Mobile%20Footer&af_web_dp=https%3A%2F%2Fagariogame.net%2Fprofiles.newsmax.com/sso/signup.aspx?ReturnURL=https%3A%2F%2Fagariogame.net%2Fdomain.opendns.com/agariogame.netapp.feedblitz.com/f/f.fbz?track=https%3A%2F%2Fagariogame.netjump.5ch.net/?agariogame.netdol.deliver.ifeng.com/c?z=ifeng&la=0&si=2&cg=1&c=1&ci=2&or=7549&l=28704&bg=28703&b=37275&u=https%3A%2F%2Fagariogame.netfeeds.gizmodo.com.au/~/t/0/0/gizmodoaustralia/~/https:/agariogame.net/www.etis.ford.com/externalURL.do?url=https%3A%2F%2Fagariogame.net%2Fid.telstra.com.au/register/crowdsupport?gotoURL=https%3A%2F%2Fagariogame.net%2Ffeeds.hanselman.com/~/t/0/0/scotthanselman/~https:/agariogame.net/bbs.pku.edu.cn/v2/jump-to.php?url=https%3A%2F%2Fagariogame.net%2Fdaemon.indapass.hu/http/session_request?redirect_to=https%3A%2F%2Fagariogame.net&partner_id=bloghuuk.advfn.com/ct.php?ct=OTk1OTg=&redir=https%3A%2F%2Fagariogame.net%2Fimages-fames.b-cdn.net/spai/w_1920+q_lossy+ret_img/https:/agariogame.net/rssfeeds.wfaa.com/~/t/0/0/wfaa/local/~https:/agariogame.net/rssfeeds.khou.com/~/t/0/0/khou/sports/~https:/agariogame.net/extras.seattlepi.com/redirect.php?url=https%3A%2F%2Fagariogame.net%2Fmember.yam.com/EDM_CLICK.aspx?EDMID=7948&EMAIL=qqbuyme.cosmo925@blogger.com&CID=103443&EDMURL=https%3A%2F%2Fagariogame.net%2Fgleam.io/zyxKd-INoWr2EMzH?l=http%3A%2F%2Fagariogame.netwww.justjaredjr.com/flagcomment.php?cl=10842755&el=https%3A%2F%2Fagariogame.netwww.edaily.co.kr/_template/popup/t_popup_click.asp?Mrseq=830&MrT=https%3A%2F%2Fagariogame.net%2Fssl.cosme.net/cosme/asp/buy/buy0002.asp?rurl=https%3A%2F%2Fagariogame.net%2Fwww.google.tn/url?sa=t&url=https%3A%2F%2Fagariogame.netrssfeeds.wkyc.com/~/t/0/0/wkyc/news/~https:/agariogame.net/www2.ogs.state.ny.us/help/urlstatusgo.html?url=https://agariogame.netfeeds.kotaku.com.au/~/t/0/0/kotakuaustralia/~/https:/agariogame.net/aquaculture.seagrant.uaf.edu/click-thru.html?id=151&url=https%3A%2F%2Fagariogame.net%2Fscanmail.trustwave.com/?c=8510&d=4qa02KqxZJadHuhFUvy7ZCUfI_2L10yeH0EeBz7FGQ&u=https%3A%2F%2Fagariogame.netrssfeeds.13newsnow.com/~/t/0/0/wvec/local/~https:/agariogame.net/scribd.page.link/?amv=9.1.0&apn=com.scribd.app.reader0&ibi=com.scribd.iscribd&imv=9.1.1&isi=542557212&link=https%3A%2F%2Fagariogame.net%2Fforums.thesims.com/en_uS/home/leaving/agariogame.netposts.google.com/url?sa=t&url=https%3A%2F%2Fagariogame.net%2Fxat.com/web_gear/chat/linkvalidator.php?link=https%3A%2F%2Fagariogame.netadvisor.wmtransfer.com/SiteDetails.aspx?url=agariogame.netwww.nordbayern.de/logoutservlet?logout_referer=https%3A%2F%2Fagariogame.net%2Fwww.bad.org.uk/for-the-public/patient-information-leaflets/androgenetic-alopecia/?showmore=1&returnlink=https%3A%2F%2Fagariogame.net%2Frssfeeds.kens5.com/~/t/0/0/business/~https:/agariogame.net/%2Fwww.winnipegfreepress.com/s?action=doLogout&rurl=http%3A%2F%2Fagariogame.netfjb.kaskus.co.id/redirect?url=https%3A%2F%2Fagariogame.net%2Fpantip.com/l/https:%E0%B8%AF%E0%B9%91%E0%B8%AF%E0%B8%AF%E0%B9%91%E0%B8%AFagariogame.net%2F/3918rssfeeds.wbir.com/~/t/0/0/wbir/local_news/~https:/agariogame.net/innuityweb.myregisteredsite.com/admin/membership_agreement.php?partnerID=3185&domain=agariogame.netfeeds.lifehacker.com.au/~/t/0/0/lifehackeraustralia/~/https:/agariogame.net/www.london.umb.edu/?URL=https%3A%2F%2Fagariogame.net%2Fwww.fito.nnov.ru/go.php?url=https%3A%2F%2Fagariogame.netwww.vreddiehgdl.cucsh.udg.mx/sites/all/modules/pubdlcnt/pubdlcnt.php?file=https%3A%2F%2Fagariogame.net%2F&nid=126passport-us.bignox.com/sso/logout?service=https%3A%2F%2Fagariogame.net%2Fwww.talgov.com/Main/exit.aspx?url=https%3A%2F%2Fagariogame.netf5.glitch.me/proxy/https%3A%2F%2Fagariogame.net%2Fsc.hkexnews.hk/TuniS/agariogame.net/www.curseforge.com/linkout?remoteUrl=https%3A%2F%2Fagariogame.net%2Fclient.paltalk.com/client/webapp/client/External.wmt?url=http%3A%2F%2Fagariogame.nettools.folha.com.br/print?url=https%3A%2F%2Fagariogame.netes.catholic.net/ligas/ligasframe.phtml?liga=https%3A%2F%2Fagariogame.net%2Fwww.interempresas.net/estadisticas/r.asp?idsector=129&e=221083&c=195&d=https%3A%2F%2Fagariogame.net%2Fsinp.msu.ru/ru/ext_link?url=https%3A%2F%2Fagariogame.net%2Frssfeeds.mycentraljersey.com/~/t/0/0/bridgewater/home/~https:/agariogame.net/sherlock.scribblelive.com/r?u=agariogame.netgeomorphology.irpi.cnr.it/map-services/android-guide/@@reset-optout?came_from=https%3A%2F%2Fagariogame.net%2Fceskapozice.lidovky.cz/redir.aspx?url=http%3A%2F%2Fagariogame.nettrack.effiliation.com/servlet/effi.redir?id_compteur=22157233&effi_id=leparfroid244&url=https%3A%2F%2Fagariogame.net%2Fwww.spiritfanfiction.com/link?l=https%3A%2F%2Fagariogame.netfeeds.osce.org/~/t/0/0/oscelatestnews/~https:/agariogame.net/%2Fwww.omnigroup.com/omnifocus/?URL=agariogame.netreelgood.com/https:/agariogame.net/www.triathlon.org/?URL=agariogame.net/stmassey.f2s.com/?URL=https%3A%2F%2Fagariogame.net%2Fmisc.symbaloo.com/redirect.php?network=tradetracker&campaignID=480&url=https%3A%2F%2Fagariogame.net%2Frd.alice.it/r3/redir.asp?URL=https%3A%2F%2Fagariogame.net%2Farctic.nyheter24.se/rdb/nyheter24_eed6ad4b451f2fb8193922f832bc91ed/5?url=https%3A%2F%2Fagariogame.net%2Fams.ceu.edu/optimal/optimal.php?url=https%3A%2F%2Fagariogame.net%2Fwww.meetme.com/apps/redirect/?url=agariogame.net/clients1.google.tk/url?q=https%3A%2F%2Fagariogame.netwww.aaronsw.com/2002/display.cgi?t=%3Ca+href=https%3A%2F%2Fagariogame.netwww.kichink.com/home/issafari?uri=https%3A%2F%2Fagariogame.net%2Flaw.spbu.ru/aboutfaculty/teachers/teacherdetails/a7fb1dbb-e9f3-4fe9-91e9-d77a53b8312c.aspx?returnurl=https%3A%2F%2Fagariogame.netenseignants.flammarion.com/Banners_Click.cfm?ID=86&URL=agariogame.net/odmp.org/link?url=https%3A%2F%2Fagariogame.net%2Fwww.swrve.com/?URL=agariogame.netsc.hkex.com.hk/TuniS/agariogame.net/redir.speedbit.com/redir.asp?id=8030&urldirect=https%3A%2F%2Fagariogame.netmitsui-shopping-park.com/lalaport/iwata/redirect.html?url=https%3A%2F%2Fagariogame.net%2Fmarketplace.salisburypost.com/AdHunter/salisburypost/Home/EmailFriend?url=https%3A%2F%2Fagariogame.net%2Fwww.popcouncil.org/scripts/leaving.asp?URL=http%3A%2F%2Fagariogame.netnou-rau.uem.br/nou-rau/zeus/auth.php?back=https%3A%2F%2Fagariogame.net%2F&go=x&code=x&unit=xredirect.camfrog.com/redirect/?url=https%3A%2F%2Fagariogame.net%2Fdavidbyrne.com/?URL=agariogame.netfeeds.ligonier.org/~/t/0/0/ligonierministriesblog/~/https:/agariogame.net/feeds.gty.org/~/t/0/0/gtyblog/~/https:/agariogame.net/foro.infojardin.com/proxy.php?link=https%3A%2F%2Fagariogame.netwww.ppa.com/?URL=agariogame.netimaginingourselves.globalfundforwomen.org/pb/External.aspx?url=https%3A%2F%2Fagariogame.net%2Fshorefire.com/?URL=agariogame.nettimberlinelodge.com/?URL=agariogame.netwww.earth-policy.org/?URL=agariogame.net/chtbl.com/track/118167/agariogame.net/wfc2.wiredforchange.com/dia/track.jsp?v=2&c=hdorrh%2BHcDlQ%2BzUEnZU5qlfKZ1Cl53X6&url=https%3A%2F%2Fagariogame.netwww.cheapassgamer.com/redirect.php?url=https%3A%2F%2Fagariogame.netregister.scotland.org/Subscribe/WidgetSignup?url=http%3A%2F%2Fagariogame.netinterpals.net/url_redirect.php?href=https%3A%2F%2Fagariogame.net%2Fmyemma.com/?URL=agariogame.netintellectualventures.com/?URL=agariogame.netfooyoh.com/wcn.php?url=https%3A%2F%2Fagariogame.net%2Flinabanner.jobstreet.com/redirect.asp?bid=23996&track=0&uid=&url=https%3A%2F%2Fagariogame.net%2Fwww.usich.gov/?URL=agariogame.netwww.sunvalley.com/?URL=agariogame.netipb.ac.id/lang/s/ID?url=https%3A%2F%2Fagariogame.net%2Fmoshtix.com.au/v2/ForceDesktopView?callingURL=https%3A%2F%2Fagariogame.net%2Ftapestry.tapad.com/tapestry/1?ta_partner_id=950&ta_redirect=https%3A%2F%2Fagariogame.net%2Fwww.chuys.com/?URL=agariogame.netanalytics.bluekai.com/site/16231?phint=event=click&phint=campaign=BRAND-TAB&phint=platform=search&done=agariogame.netshop.wki.it/shared/sso/sso.aspx?sso=G7OBN320AS3T48U0ANSN3KMN22&url=https%3A%2F%2Fagariogame.net%2Fwww.kunstsammlung.de/?URL=agariogame.netwww.malcolmturnbull.com.au/?URL=agariogame.netsc.sie.gov.hk/TuniS/agariogame.net/ref.webhostinghub.com/scripts/click.php?ref_id=nichol54&desturl=https%3A%2F%2Fagariogame.net%2Fthewomens.org.au/?URL=agariogame.netwww.hockney.com/?URL=agariogame.netwww.ch7.com/?URL=agariogame.netwww.asma.org/impakredirect.aspx?url=agariogame.net/www.venez.fr/error.fr.html?id=1&uri=https%3A%2F%2Fagariogame.net%2Fwww.octranspo.com/en/about-us/confederation-line-1-website?URL=agariogame.netlogin.mephi.ru/login?allow_anonymous=true&service=https%3A%2F%2Fagariogame.net%2Fww4.cef.es/trk/r.emt?h=agariogame.net/cientec.or.cr/ligas-externas/redir.phtml?link=agariogame.net/fr.grepolis.com/start/redirect?url=https%3A%2F%2Fagariogame.net%2Farchives.midweek.com/?URL=https%253A%252F%252Fagariogame.net/www.ahewar.org/links/dform.asp?url=https%3A%2F%2Fagariogame.net%2Flogin.aup.edu/cas/login?service=https%3A%2F%2Fagariogame.net%2F/&gateway=truewww.sitesimilar.net/agariogame.netyumi.rgr.jp/puku-board/kboard.cgi?mode=res_html&owner=proscar&url=agariogame.net/intranet.canadabusiness.ca/?URL=agariogame.net/sc.devb.gov.hk/TuniS/agariogame.net/anonym.to/?http%3A%2F%2Fagariogame.net/www.ait.ie/?URL=agariogame.netnews.url.google.com/url?q=https%3A%2F%2Fagariogame.netm.ok.ru/dk?st.cmd=outLinkWarning&st.rfn=https%3A%2F%2Fagariogame.net%2F agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario agario zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 zafer2 agario agario agario agario agario agario agario agario agario agario agario agario agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked agario unblocked P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P  P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.