11#! groovy
22
33pipeline {
4- agent any
5-
6- tools {
7- jdk ' oracle-jdk8-latest'
4+ agent {
5+ label " docker-build"
86 }
9-
7+
108 options {
119 timestamps()
1210 skipStagesAfterUnstable()
@@ -21,23 +19,60 @@ pipeline {
2119
2220 def sys_info = sh(script : " uname -a" , returnStdout : true ). trim()
2321 println (" System information: ${ sys_info} " )
24- println (" JAVE_HOME: ${ JAVA_HOME} " )
2522
2623 sh '''
2724 java -version
2825 which java
2926 '''
3027
31- dir(' dev' ) { sh ' ./gradlew --stacktrace' }
28+ dir(' dev' ) {
29+ sh ' ./gradlew --stacktrace'
30+ }
3231 }
3332 }
3433 }
34+
35+ stage(' Test' ) {
36+ steps {
37+ script {
38+ sh ''' #!/usr/bin/env bash
39+ docker build --no-cache -t test-image ./dev
40+ export CWD=$(pwd)
41+ echo "Current directory is ${CWD}"
42+ docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${CWD}/dev:/development test-image
43+
44+ rm $WORKSPACE/dev/ant_build/artifacts/codewind-openapi-eclipse-test-*.zip
45+ '''
46+ dir(' dev' ) {
47+ stash name : ' codewind-openapi-eclipse-zip' , includes : ' ant_build/artifacts/codewind-openapi-eclipse-*.zip'
48+ }
49+ }
50+ }
51+ }
3552
3653 stage(' Deploy' ) {
54+ // This when clause disables PR build uploads; you may comment this out if you want your build uploaded.
55+ when {
56+ beforeAgent true
57+ not {
58+ changeRequest()
59+ }
60+ }
61+
62+ options {
63+ skipDefaultCheckout()
64+ }
65+
66+ agent any
67+
3768 steps {
3869 sshagent ( [' projects-storage.eclipse.org-bot-ssh' ]) {
3970 println (" Deploying codewind-openapi-eclipse to downoad area..." )
40-
71+
72+ dir(" $WORKSPACE /dev" ) {
73+ unstash ' codewind-openapi-eclipse-zip'
74+ }
75+
4176 sh '''
4277 export REPO_NAME="codewind-openapi-eclipse"
4378 export OUTPUT_NAME="codewind-openapi-eclipse"
@@ -48,8 +83,6 @@ pipeline {
4883 export sshHost="genie.codewind@projects-storage.eclipse.org"
4984 export deployDir="/home/data/httpd/download.eclipse.org/codewind/$REPO_NAME"
5085
51- rm $OUTPUT_DIR/$REPO_NAME-test-*.zip
52-
5386 if [ -z $CHANGE_ID ]; then
5487 UPLOAD_DIR="$GIT_BRANCH/$BUILD_ID"
5588 BUILD_URL="$DOWNLOAD_AREA_URL/$UPLOAD_DIR"
@@ -81,5 +114,19 @@ pipeline {
81114 }
82115 }
83116 }
84- }
117+ }
118+
119+ post {
120+ always {
121+ sh ''' #!/usr/bin/env bash
122+ # Docker system prune
123+ echo "Docker system prune ..."
124+ docker system df
125+ docker system prune -a --volumes -f
126+ docker builder prune -a -f
127+ docker system df
128+ df -lh
129+ '''
130+ }
131+ }
85132}
0 commit comments