Skip to content

Commit

Permalink
[jenkins]: Move script out of Jenkinsfile for re-use purpose (#35)
Browse files Browse the repository at this point in the history
Make the files DRY

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shuotian Cheng authored Jun 13, 2019
1 parent b4c4992 commit 6bf888f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 101 deletions.
63 changes: 12 additions & 51 deletions jenkins/common/sonic-swss-common-build-pr/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,25 @@ pipeline {
stages {
stage('Prepare') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: '${sha1}']],
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: false,
recursiveSubmodules: false,
reference: '',
trackingSubmodules: false]],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-swss-common',
refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
dir('sonic-swss-common') {
checkout([$class: 'GitSCM',
branches: [[name: '${sha1}']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-swss-common',
refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
}
copyArtifacts(projectName: 'vs/buildimage-vs-all', filter: '**/*.deb', target: 'buildimage', flatten: false)

}
}

stage('Build') {
steps {
sh '''
#!/bin/bash -x
# Install swig3.0
sudo dpkg -i buildimage/target/debs/stretch/swig3.0_*.deb
# Install REDIS
sudo dpkg -i buildimage/target/debs/stretch/redis-tools_*.deb
sudo dpkg -i buildimage/target/debs/stretch/redis-server_*.deb
sudo sed -i 's/notify-keyspace-events ""/notify-keyspace-events AKE/' /etc/redis/redis.conf
sudo service redis-server start
# Install HIREDIS
sudo dpkg -i buildimage/target/debs/stretch/libhiredis*.deb
# Install libnl3
sudo dpkg -i buildimage/target/debs/stretch/libnl-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-genl-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-genl-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-route-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-route-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-nf-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-nf-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-cli-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-cli-3-dev_*.deb
./autogen.sh
fakeroot debian/rules binary
mkdir target
cp ../*.deb target/
# Test
sudo dpkg -i ../libswsscommon_*.deb
sudo dpkg -i ../python-swsscommon_*.deb
sudo ./tests/tests
sh './scripts/common/sonic-swss-common-build/build.sh'
}
}

redis-cli FLUSHALL
py.test tests
'''
stage('Test') {
steps {
sh './scripts/common/sonic-swss-common-build/test.sh'
}
}
}
Expand Down
61 changes: 11 additions & 50 deletions jenkins/common/sonic-swss-common-build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,24 @@ pipeline {
stages {
stage('Prepare') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: false,
recursiveSubmodules: false,
reference: '',
trackingSubmodules: false]],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-swss-common']]])
dir('sonic-swss-common') {
checkout([$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-swss-common']]])
}
copyArtifacts(projectName: '../vs/buildimage-vs-all', filter: '**/*.deb', target: 'buildimage', flatten: false)

}
}

stage('Build') {
steps {
sh '''
#!/bin/bash -x
# Install swig3.0
sudo dpkg -i buildimage/target/debs/stretch/swig3.0_*.deb
# Install REDIS
sudo dpkg -i buildimage/target/debs/stretch/redis-tools_*.deb
sudo dpkg -i buildimage/target/debs/stretch/redis-server_*.deb
sudo sed -i 's/notify-keyspace-events ""/notify-keyspace-events AKE/' /etc/redis/redis.conf
sudo service redis-server start
# Install HIREDIS
sudo dpkg -i buildimage/target/debs/stretch/libhiredis*.deb
# Install libnl3
sudo dpkg -i buildimage/target/debs/stretch/libnl-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-genl-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-genl-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-route-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-route-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-nf-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-nf-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-cli-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-cli-3-dev_*.deb
./autogen.sh
fakeroot debian/rules binary
mkdir target
cp ../*.deb target/
# Test
sudo dpkg -i ../libswsscommon_*.deb
sudo dpkg -i ../python-swsscommon_*.deb
sudo ./tests/tests
sh './scripts/common/sonic-swss-common-build/build.sh'
}
}

redis-cli FLUSHALL
py.test tests
'''
stage('Test') {
steps {
sh './scripts/common/sonic-swss-common-build/test.sh'
}
}
}
Expand Down
34 changes: 34 additions & 0 deletions scripts/common/sonic-swss-common-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -x

# Install SWIG
sudo dpkg -i buildimage/target/debs/stretch/swig3.0_*.deb

# Install Redis
sudo dpkg -i buildimage/target/debs/stretch/redis-tools_*.deb
sudo dpkg -i buildimage/target/debs/stretch/redis-server_*.deb

# Install HIREDIS
sudo dpkg -i buildimage/target/debs/stretch/libhiredis*.deb

# Install libnl3
sudo dpkg -i buildimage/target/debs/stretch/libnl-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-genl-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-genl-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-route-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-route-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-nf-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-nf-3-dev_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-cli-3-200_*.deb
sudo dpkg -i buildimage/target/debs/stretch/libnl-cli-3-dev_*.deb

pushd sonic-swss-common

./autogen.sh
fakeroot debian/rules binary

popd

mkdir target
cp *.deb target/

16 changes: 16 additions & 0 deletions scripts/common/sonic-swss-common-build/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -x

sudo sed -i 's/notify-keyspace-events ""/notify-keyspace-events AKE/' /etc/redis/redis.conf
sudo service redis-server start

sudo dpkg -i libswsscommon_*.deb
sudo dpkg -i python-swsscommon_*.deb

pushd sonic-swss-common

sudo ./tests/tests

redis-cli FLUSHALL
py.test tests

popd

0 comments on commit 6bf888f

Please sign in to comment.