Romain Grecourt | 3230dc4 | 2019-02-26 15:26:54 -0800 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | |
| 3 | // the label is unique and identifies the pod descriptor and its resulting pods |
| 4 | // without this, the agent could be using a pod created from a different descriptor |
| 5 | def label = "glassfish-ci-${UUID.randomUUID().toString()}" |
| 6 | podTemplate(label: label, yaml: """ |
| 7 | apiVersion: v1 |
| 8 | kind: Pod |
| 9 | spec: |
| 10 | securityContext: |
| 11 | runAsUser: 1000100000 |
| 12 | containers: |
| 13 | - name: glassfish-ci |
| 14 | image: ee4jglassfish/ci:jdk-8.181 |
| 15 | args: |
| 16 | - cat |
| 17 | tty: true |
| 18 | imagePullPolicy: Always |
| 19 | resources: |
| 20 | limits: |
| 21 | memory: "7Gi" |
| 22 | cpu: "3" |
| 23 | """ |
| 24 | ) { |
| 25 | node (label) { |
| 26 | def CREDENTIALS_ID='902aa4fe-7457-47e3-b3c4-de5a4c33b9c5' |
| 27 | container('glassfish-ci') { |
| 28 | sshagent([CREDENTIALS_ID]) { |
| 29 | sh ''' |
| 30 | set -e |
| 31 | |
| 32 | SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" |
| 33 | SSH_HOST="genie.glassfish@projects-storage.eclipse.org" |
| 34 | STAGING_PATH="/home/data/httpd/download.eclipse.org/glassfish/" |
| 35 | |
| 36 | # Print the number of colons in a string |
| 37 | # arg1 - string |
| 38 | numColons(){ |
| 39 | local str="${1}" |
| 40 | local colons="${str//[^:]}" |
| 41 | echo "${#colons}" |
| 42 | } |
| 43 | |
| 44 | # Download a bundle from Maven Central |
| 45 | # arg1 - gav (groupID:artifactID:version[:classifier]:type) |
| 46 | downloadBundle(){ |
| 47 | local gav=${1} |
| 48 | local numC=`numColons "${gav}"` |
| 49 | if [ "${numC}" != "3" ] && [ "${numC}" != "4" ] ; then |
| 50 | echo "Bad GAV format: ${gav}" |
| 51 | return 1 |
| 52 | fi |
| 53 | local groupId=`echo ${gav} | cut -d ':' -f1` |
| 54 | local artifactId=`echo ${gav} | cut -d ':' -f2` |
| 55 | local version=`echo ${gav} | cut -d ':' -f3` |
| 56 | local fname="${artifactId}-${version}" |
| 57 | if [ "${numC}" = "3" ] ; then |
| 58 | fname="${fname}.`echo ${gav} | cut -d ':' -f4`" |
| 59 | else |
| 60 | fname="${fname}-`echo ${gav} | cut -d ':' -f4`.`echo ${gav} | cut -d ':' -f5`" |
| 61 | fi |
| 62 | curl "https://repo1.maven.org/maven2/${groupId//.//}/${artifactId}/${version}/${fname}" > bundles/${fname} |
| 63 | } |
| 64 | |
| 65 | # download all given bundles from Maven Central |
| 66 | rm -rf bundles && mkdir -p bundles |
| 67 | IFS=, |
| 68 | for gav in ${BUNDLES_GAV} ; do |
| 69 | downloadBundle "${gav}" |
| 70 | done |
| 71 | |
| 72 | # upload them to download.eclipse.org |
| 73 | eval "ssh ${SSH_OPTS} ${SSH_HOST} mkdir -p ${STAGING_PATH}" |
| 74 | eval "scp ${SSH_OPTS} -r bundles/* ${SSH_HOST}:${STAGING_PATH}" |
| 75 | ''' |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |