diff --git a/Jenkinsfile b/Jenkinsfile index 04053c6..92c43c7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,36 +20,65 @@ */ // Load Jenkins shared libraries common to all projects -def libCmn = [ +def libLazy = [ remote: 'https://code.in.digital-me.nl/git/DEVops/JenkinsLibLazy.git', branch: env.BRANCH_NAME, credentialsId: null, ] library( - identifier: "libCmn@${libCmn.branch}", + identifier: "libLazy@${libLazy.branch}", retriever: modernSCM([ $class: 'GitSCMSource', - remote: libCmn.remote, - credentialsId: libCmn.credentialsId + remote: libLazy.remote, + credentialsId: libLazy.credentialsId + ]) +) + +// Load Jenkins shared libraries to customize this project +def libCustom = [ + remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', + branch: env.BRANCH_NAME, + credentialsId: 'bot-ci-dgm-rsa', +] + +library( + identifier: "libCustom@${libCustom.branch}", + retriever: modernSCM([ + $class: 'GitSCMSource', + remote: libCustom.remote, + credentialsId: libCustom.credentialsId ]) ) // Initialize configuration lazyConfig( - name: 'dummy-jenkins-pl', - dists: ['ubuntu-16', 'centos-7'], - labels: [ default: 'master', docker: 'docker', mac: 'mac', android: 'android', ] + name: 'dummy-jenkins-pl', + env: [ DRYRUN: true, VERSION: '0.0.1', PUBLISH: false, ], + inLabels: [ 'ubuntu-16', 'centos-7' ], + onLabels: [ default: 'master', docker: 'docker', mac: 'mac', android: 'android', ], + noPoll: '.+_.+', ) lazyStage { name = 'validate' tasks = [ - [ run: { echo "This is my first task" }, ], + [ + run: { + echo "This is my first task"/* + gitLog('27e440f290d8bf95a3908cad03a5588fc2f2fe73') + lazyGitPass('bot-ci-dgm', { + gitTag('test-0.0.1') + }) */ + echo "Creating repo with packages" + if (lazyConfig.DRYRUN) { echo "DRYRUN is true = ${env.DRYRUN}" } + if (lazyConfig.DRYRUN) { echo "DRYRUN is false = ${env.DRYRUN}" } + }, + ], [ run: { echo "This is my second task" }, in: '*', on: 'docker' ], - [ run: "third.sh", in: [ 'ubuntu-16', 'centos-7'], on: 'docker',], - [ run: [ "fourth-a.sh", "fourth-b.sh"], on: 'mac' ], - [ run: [ "fourth-a.sh", "fourth-b.sh"], on: 'android' ], + [ run: "third.sh -v", in: [ 'ubuntu-16', 'centos-7'], on: 'docker',], + [ run: [ "fourth-a.sh -v -m c", "fourth-b.sh -v -m d"], on: 'mac' ], + [ run: [ "fourth-a.sh -v -m e", "fourth-b.sh -v -m f"], on: 'android' ], ] } @@ -75,20 +104,35 @@ // [ run: { echo "Building packages"; echo "Archive packages"; }, on: 'windows', ] // [ run: { echo "Building packages"; echo "Archive packages"; }, on: 'mac', ] [ - run: { echo "Building packages"; }, + run: { + echo "Building packages"; + sh "mkdir -p target/packages && echo 'testpkg' > target/packages/\${LAZY_LABEL}.pkg" + }, in: [ 'ubuntu-16', 'centos-7', ], on: 'docker', - post: { echo "Archiving packages" }, + post: { + echo "Archiving packages" + archiveArtifacts(artifacts: 'target/packages/**', allowEmptyArchive: false) + }, ], ] } lazyStage { name = 'publish' + onlyif = ( env.LAZY_BRANCH == 'master' || lazyConfig.env.PUBLISH ) tasks = [ [ - pre: { echo "Unarchiving packages" }, - run: { echo "Creating repo with packages" }, + pre: { + echo "Unarchiving packages" + unarchive(mapping:['target/packages/' : '.']) + sh("ls -lA target/packages") + }, + run: { + echo "Creating repo with packages" + if (lazyConfig.env.DRYRUN) { echo "DRYRUN is true = ${lazyConfig.env.DRYRUN}" } + if (!lazyConfig.env.DRYRUN) { echo "DRYRUN is false = ${lazyConfig.env.DRYRUN}" } + }, in: [ 'ubuntu-16', 'centos-7', ], on: 'docker', post: { echo "Publishing package repos" }, diff --git a/lazyDir/centos-7.Dockerfile b/lazyDir/centos-7.Dockerfile index 80e3b72..20e85c8 100644 --- a/lazyDir/centos-7.Dockerfile +++ b/lazyDir/centos-7.Dockerfile @@ -1,18 +1,22 @@ # Pull base image from official repo -FROM centos:centos7.4.1708 +FROM centos:centos7.5.1804 -# Install all current updates -RUN yum -q clean expire-cache \ +# Enable epel repo and Install all current updates +RUN yum -q -y update \ + && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \ + && yum -y install epel-release \ + && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \ && yum -y upgrade \ - && yum -q clean packages + && yum -q clean all # Install common requirements -RUN yum -q clean expire-cache \ +RUN yum -q -y update \ && yum -y install \ git \ wget \ unzip \ - && yum -q clean packages + which \ + && yum -q clean all # Add user to build and package ARG uid=1000 @@ -21,3 +25,6 @@ ARG group=dummy RUN groupadd -g "${gid}" "${group}" && useradd -ms /bin/bash -g "${group}" -u "${uid}" "${user}" + +# Get script directory from lazyLib +ARG dir=. diff --git a/lazyDir/ubuntu-16.Dockerfile b/lazyDir/ubuntu-16.Dockerfile index ed7b9c1..bdb260a 100644 --- a/lazyDir/ubuntu-16.Dockerfile +++ b/lazyDir/ubuntu-16.Dockerfile @@ -21,3 +21,6 @@ ARG group=dummy RUN groupadd -g "${gid}" "${group}" && useradd -ms /bin/bash -g "${group}" -u "${uid}" "${user}" + +# Get script directory from lazyLib +ARG dir=. diff --git a/lazyDir/validate/fourth-a.sh b/lazyDir/validate/fourth-a.sh index fdba0eb..afac1f9 100755 --- a/lazyDir/validate/fourth-a.sh +++ b/lazyDir/validate/fourth-a.sh @@ -16,4 +16,7 @@ # limitations under the License. echo "Start ${0} script..." +if [ "${1}" = '-v' ]; then + echo "Mode = ${3}" +fi echo "Stop ${0} script..." diff --git a/lazyDir/validate/fourth-b.sh b/lazyDir/validate/fourth-b.sh index fdba0eb..afac1f9 100755 --- a/lazyDir/validate/fourth-b.sh +++ b/lazyDir/validate/fourth-b.sh @@ -16,4 +16,7 @@ # limitations under the License. echo "Start ${0} script..." +if [ "${1}" = '-v' ]; then + echo "Mode = ${3}" +fi echo "Stop ${0} script..." diff --git a/lazyDir/validate/third.sh b/lazyDir/validate/third.sh index 66d72ed..8d59b0a 100755 --- a/lazyDir/validate/third.sh +++ b/lazyDir/validate/third.sh @@ -18,4 +18,7 @@ # limitations under the License. echo "Start ${0} script..." +if [ "${1}" = '-v' ]; then + env | sort +fi echo "Stop ${0} script..."