diff --git a/Jenkinsfile b/Jenkinsfile index cc6654f..6313b51 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,8 +21,8 @@ // Load Jenkins shared libraries common to all projects def libLazy = [ - remote: 'https://code.in.digital-me.nl/git/DEVops/JenkinsLibLazy.git', - branch: 'master', + remote: 'https://github.com/digital-me/jenkins-lib-lazy.git', + branch: 'stable', credentialsId: null, ] @@ -32,13 +32,14 @@ $class: 'GitSCMSource', remote: libLazy.remote, credentialsId: libLazy.credentialsId - ]) + ]), + changelog: false, ) // Load Jenkins shared libraries to customize this project def libCustom = [ remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', - branch: 'master', + branch: 'stable', credentialsId: 'bot-ci-dgm-rsa', ] @@ -48,13 +49,14 @@ $class: 'GitSCMSource', remote: libCustom.remote, credentialsId: libCustom.credentialsId - ]) + ]), + changelog: false, ) // Define the remotes and the working and deploy branches def remote = 'origin' def workingBranch = 'master' -def releaseBranch = 'release' +def releaseBranch = 'stable' // Initialize configuration lazyConfig( @@ -73,9 +75,10 @@ DEPLOY_DIR: '/var/www/html/public/dummy-jenkins-pl', DEPLOY_CRED: 'bot-ci-dgm-rsa', ], - inLabels: [ 'ubuntu-16', 'centos-7' ], - onLabels: [ default: 'master', docker: 'docker', mac: 'mac', android: 'android', ], - noPoll: "(.+_.+)", // Don't poll or automatically trigger private branches + inLabels: [ 'ubuntu16', 'centos7' ], + onLabels: [ default: 'master', docker: 'docker', mac: 'mac', android: 'android', ], + noIndex: "(${releaseBranch}|.+_.+)", // Avoid automatic indexing for release and private branches + xmppTargets: 'noise@conference.qiy.nl', ) lazyStage { @@ -84,18 +87,21 @@ tasks = [ [ pre: { - def currentVersion = gitLastTag() + def currentVersion = null + gitAuth(env.GIT_CRED, { + currentVersion = gitLastTag('*.*.*-*') + }) currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion}" }, run: { echo "This is my first task" }, ], - [ run: { echo "This is my second task" }, in: '*', on: 'docker' ], - [ run: "third.sh -v", in: [ 'ubuntu-16', 'centos-7'], on: 'docker',], +/* [ run: { echo "This is my second task" }, in: '*', on: 'docker' ], + [ run: "third.sh -v", in: [ 'ubuntu16', 'centos7'], 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' ], - ] +*/ ] } lazyStage { @@ -126,18 +132,17 @@ // Read version from last git tag first def currentVersion = null gitAuth(env.GIT_CRED, { - currentVersion = gitLastTag() + currentVersion = gitLastTag('*.*.*-*') }) - if (lazyConfig['branch'] == releaseBranch) { - // Checkout the last changes from the tag created in release stage - sh("git checkout tags/${currentVersion}") - } else { + if (lazyConfig['branch'] != releaseBranch) { // Write version from last tag to generate the site writeFile(encoding: 'UTF-8', file: 'version.txt', text: currentVersion) } currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion}" }, run: { + // Update package metadata to the current version + def currentVersion = readFile(encoding: 'UTF-8', file: 'version.txt') sh "mkdir -p ${env.BUILD_DIR} && echo 'testpkg-${currentVersion}' > ${env.BUILD_DIR}/\${LAZY_LABEL}.pkg" }, post: { @@ -184,10 +189,12 @@ gitCommit("Update version to ${nextVersion}", 'version.txt') // Uncomment the following to merge version bump back into the working branch //gitMerge(releaseBranch, workingBranch) - //gitPush(remote, workingBranch) - // Publish changes in release branch and tag the release - gitPush(remote, releaseBranch) - gitTag("${nextVersion}", remote) + // Tag and publish changes in release branch + gitTag("${nextVersion}") + gitPush(remote, "${releaseBranch} ${nextVersion}") + // Update the displayed version for this build + currentVersion = gitLastTag() + currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion}" }) }, // Can not be done in parallel @@ -210,7 +217,7 @@ post: { echo "Publishing package repos" sshagent(credentials: [env.DEPLOY_CRED]) { - sshDeploy(env.BUILD_DIR, "${env.DEPLOY_USER}@${env.DEPLOY_HOST_STST}", env.DEPLOY_DIR, 'rsync') + sshDeploy(env.BUILD_DIR, "${env.DEPLOY_USER}@${env.DEPLOY_HOST_STST}", env.DEPLOY_DIR, 'rsync', false, '-hrlpgolzciu') } archiveArtifacts(artifacts: "${env.BUILD_DIR}/**", allowEmptyArchive: false) }, @@ -227,8 +234,8 @@ }, run: { sshagent(credentials: [env.DEPLOY_CRED]) { - sshDeploy(env.BUILD_DIR, "${env.DEPLOY_USER}@${env.DEPLOY_HOST_ACC1}", env.DEPLOY_DIR, 'rsync') - sshDeploy(env.BUILD_DIR, "${env.DEPLOY_USER}@${env.DEPLOY_HOST_ACC2}", env.DEPLOY_DIR, 'rsync') + sshDeploy(env.BUILD_DIR, "${env.DEPLOY_USER}@${env.DEPLOY_HOST_ACC1}", env.DEPLOY_DIR, 'rsync', false, '-hrlpgolzciu') + sshDeploy(env.BUILD_DIR, "${env.DEPLOY_USER}@${env.DEPLOY_HOST_ACC2}", env.DEPLOY_DIR, 'rsync', false, '-hrlpgolzciu') } }, in: '*', diff --git a/lazyDir/centos-7.Dockerfile b/lazyDir/centos-7.Dockerfile deleted file mode 100644 index 20e85c8..0000000 --- a/lazyDir/centos-7.Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Pull base image from official repo -FROM centos:centos7.5.1804 - -# 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 all - -# Install common requirements -RUN yum -q -y update \ - && yum -y install \ - git \ - wget \ - unzip \ - which \ - && yum -q clean all - -# Add user to build and package -ARG uid=1000 -ARG user=dummy -ARG gid=1000 -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/centos6.Dockerfile b/lazyDir/centos6.Dockerfile new file mode 100644 index 0000000..ff9cf24 --- /dev/null +++ b/lazyDir/centos6.Dockerfile @@ -0,0 +1,76 @@ +# +# This work is protected under copyright law in the Kingdom of +# The Netherlands. The rules of the Berne Convention for the +# Protection of Literary and Artistic Works apply. +# Digital Me B.V. is the copyright owner. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Pull base image from official repo +FROM centos:centos6.10 + +# Import local GPG keys and enable epel repo +RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 && \ + yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs epel-release && \ + rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 && \ + yum -q -y clean all --enablerepo='*' + +# Install common requirements +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + git \ + wget \ + unzip \ + which \ + && \ + yum -q -y clean all --enablerepo='*' + +# Import extra GPG keys +RUN rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppet && \ + rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs && \ + rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB + +# Add internal CA +RUN wget -q https://share.qiy.nl/public/certs/ca-digital-me-private-2026.crt -O /etc/pki/ca-trust/source/anchors/ca-digital-me-internal.pem && \ + update-ca-trust force-enable && \ + update-ca-trust extract + +# Configure global Yum repos +RUN rm -f /etc/yum.repos.d/*.repo && \ + echo '[all]' > /etc/yum.repos.d/all.repo && \ + echo 'name=Private - centos6-x86_64 - All' >> /etc/yum.repos.d/all.repo && \ + echo 'baseurl=https://mrepo.boxtel/mrepo/testci/centos6-x86_64/RPMS.all' >> /etc/yum.repos.d/all.repo && \ + echo 'enabled=1' >> /etc/yum.repos.d/all.repo + +# Install something and its requirements +#RUN yum -q clean expire-cache && \ +# yum -q -y update && \ +# yum -y install --setopt=tsflags=nodocs \ +# ... +# && \ +# yum -q -y clean all --enablerepo='*' + +# Add a dummy user +ARG uid=1000 +ARG user=dummy +ARG gid=1000 +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/centos7.Dockerfile b/lazyDir/centos7.Dockerfile new file mode 100644 index 0000000..3cca266 --- /dev/null +++ b/lazyDir/centos7.Dockerfile @@ -0,0 +1,69 @@ +# +# This work is protected under copyright law in the Kingdom of +# The Netherlands. The rules of the Berne Convention for the +# Protection of Literary and Artistic Works apply. +# Digital Me B.V. is the copyright owner. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Pull base image from official repo +FROM centos:centos7.8.2003 + +# Import local GPG keys and enable epel repo +RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \ + yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs epel-release && \ + rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && \ + yum -q -y clean all --enablerepo='*' + +# Install common requirements +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + git \ + wget \ + unzip \ + which \ + && \ + yum -q -y clean all --enablerepo='*' + +# Import extra GPG keys +RUN rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppet && \ + rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs && \ + rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB + +# Add internal CA +RUN wget -q https://share.qiy.nl/public/certs/ca-digital-me-private-2026.crt -O /etc/pki/ca-trust/source/anchors/ca-digital-me-internal.pem && \ + update-ca-trust force-enable && \ + update-ca-trust extract + +# Install something and its requirements +#RUN yum -q clean expire-cache && \ +# yum -q -y update && \ +# yum -y install --setopt=tsflags=nodocs \ +# ... +# && \ +# yum -q -y clean all --enablerepo='*' + +# Add user to build and package +ARG uid=1000 +ARG user=dummy +ARG gid=1000 +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 deleted file mode 100644 index bdb260a..0000000 --- a/lazyDir/ubuntu-16.Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# Pull base image from official repo -FROM ubuntu:16.04 - -# Install all current updates -RUN apt-get -y update \ - && apt-get -y dist-upgrade \ - && apt-get clean - -# Install common requirements -RUN apt-get -y update \ - && apt-get -y install \ - git \ - wget \ - unzip \ - && apt-get clean - -# Add user to build and package -ARG uid=1000 -ARG user=dummy -ARG gid=1000 -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/ubuntu16.Dockerfile b/lazyDir/ubuntu16.Dockerfile new file mode 100644 index 0000000..bdb260a --- /dev/null +++ b/lazyDir/ubuntu16.Dockerfile @@ -0,0 +1,26 @@ +# Pull base image from official repo +FROM ubuntu:16.04 + +# Install all current updates +RUN apt-get -y update \ + && apt-get -y dist-upgrade \ + && apt-get clean + +# Install common requirements +RUN apt-get -y update \ + && apt-get -y install \ + git \ + wget \ + unzip \ + && apt-get clean + +# Add user to build and package +ARG uid=1000 +ARG user=dummy +ARG gid=1000 +ARG group=dummy + +RUN groupadd -g "${gid}" "${group}" && useradd -ms /bin/bash -g "${group}" -u "${uid}" "${user}" + +# Get script directory from lazyLib +ARG dir=.