| pipeline { |
| agent { |
| docker { |
| registryUrl 'https://controller.trafficserver.org/' |
| image 'controller.trafficserver.org/ats/centos:8' |
| args '-v "${HOME}"/ccache:/tmp/ccache:rw' |
| label 'branch' |
| } |
| } |
| |
| environment { |
| CCACHE_DIR = "/tmp/ccache" |
| } |
| |
| stages { |
| stage('Initialization') { |
| steps { |
| script { |
| if (! env.GITHUB_BRANCH) { |
| def bparts = env.JOB_NAME.split('/') |
| if (2 != bparts.length) { |
| error("Invalid branch name from ${JOB_NAME}") |
| } |
| env.GITHUB_BRANCH = bparts[0] |
| } |
| currentBuild.displayName = "#${BUILD_NUMBER} ${GITHUB_BRANCH}" |
| if (env.SHA1) { |
| currentBuild.description = env.SHA1 |
| } |
| sh 'printenv' |
| } |
| } |
| } |
| |
| stage('Clone') { |
| steps { |
| dir('ci') { |
| git url: 'https://github.com/apache/trafficserver-ci', |
| branch: 'main' |
| } |
| dir('src') { |
| script { |
| String branch = env.SHA1 |
| if (! branch) { |
| branch = '*/' + env.GITHUB_BRANCH |
| } |
| try { |
| checkout([$class: 'GitSCM', |
| branches: [[name: branch]], |
| userRemoteConfigs: [[url: env.GITHUB_URL]], |
| extensions: [[$class: 'CloneOption', timeout: 10]] |
| ]) |
| } catch (error) { |
| echo "Clone failed, retry" |
| retry(2) { |
| checkout([$class: 'GitSCM', |
| branches: [[name: branch]], |
| userRemoteConfigs: [[url: env.GITHUB_URL]], |
| extensions: [[$class: 'CloneOption', timeout: 10]] |
| ]) |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| stage('Build') { |
| steps { |
| dir('src') { |
| echo "Building" |
| sh ''' |
| source ../ci/jenkins/bin/environment.sh && ../ci/jenkins/bin/out_of_tree.sh |
| ''' |
| } |
| } |
| } |
| } |
| post { |
| always { |
| cleanWs() |
| } |
| } |
| } |