diff --git a/Jenkinsfile b/Jenkinsfile index c2b4256..c1d2e78 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,59 +1,82 @@ -#!/usr/bin/env groovy +#!groovy -def libInit =[ - remote: 'https://code.digital-me.nl/git/DEVops/DummyJnkLibInit.git', - branch: 'master', - credentialsId: null, +/* + * 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. + */ + +// Load Jenkins shared libraries common to all projects +def libCmn = [ + remote: 'https://code.in.digital-me.nl/git/DEVops/JenkinsLibLazy.git', + branch: env.BRANCH_NAME, + credentialsId: null, ] -try { - echo 'Trying to load shared libraries...' - library identifier: "libInit@${libInit.branch}", retriever: modernSCM( - [$class: 'GitSCMSource', - remote: libInit.remote, - credentialsId: libInit.credentialsId] - ) - echo 'Shared library loaded' -} catch (error) { - echo "Could not load shared libraries: ${error.message}" - exit(1) +library( + identifier: "libCmn@${libCmn.branch}", + retriever: modernSCM([ + $class: 'GitSCMSource', + remote: libCmn.remote, + credentialsId: libCmn.credentialsId + ]) +) + +// Initialize configuration +lazyConfig('dummy-jenkins-pl') + +lazyStage { + name = 'validate' + tasks = [ + [ exec: { echo "This is my first task" }, ], + [ exec: { echo "This is my second task" }, inside: '*' ], + [ exec: "third.sh", inside: [ 'ubuntu-16', 'centos-7', ] ], + [ exec: [ "fourth-a.sh", "fourth-b.sh"] ], + ] } -// Configuration -def config = initPipeline() -if (config == null) { - currentBuild.result = 'FAILURE' - return +lazyStage { + name = 'test' + tasks = [ + [ exec: { echo "This is my fith task" }, ], + [ exec: { echo "This is my sixth task" }, inside: '*' ], + ] } - -// PIPELINE -try { - stage('Static code validation') { - if (config.compile) { - label('docker') { - echo 'Validation goes here' - } - } else { - echo 'Not validating' - } - } - stage('Test') { - if (config.test) { - label('docker') { - echo 'Testing goes here...' - } - } else { - echo 'Not testing' - } - } - currentBuild.result = 'SUCCESS' -} catch (Exception error) { - currentBuild.result = 'FAILURE' -} finally { - stage('Build result notification') { - if (config.notify) { - echo 'Notification goes here' - } - } +lazyStage { + name = 'package' + tasks = [ +// [ exec: { echo "Building packages"; echo "Archive packages"; }, on: 'windows', ] +// [ exec: { echo "Building packages"; echo "Archive packages"; }, on: 'mac', ] + [ + exec: { echo "Building packages"; }, + inside: [ 'ubuntu-16', 'centos-7', ], + postout: { echo "Archiving packages" }, + ], + ] +} + +lazyStage { + name = 'publish' + tasks = [ + [ + preout: { echo "Unarchiving packages" }, + exec: { echo "Creating repo with packages" }, + inside: [ 'ubuntu-16', 'centos-7', ], + postout: { echo "Publishing package repos" }, + ], + ] } diff --git a/lazy-ci/centos-7.Dockerfile b/lazy-ci/centos-7.Dockerfile new file mode 100644 index 0000000..80e3b72 --- /dev/null +++ b/lazy-ci/centos-7.Dockerfile @@ -0,0 +1,23 @@ +# Pull base image from official repo +FROM centos:centos7.4.1708 + +# Install all current updates +RUN yum -q clean expire-cache \ + && yum -y upgrade \ + && yum -q clean packages + +# Install common requirements +RUN yum -q clean expire-cache \ + && yum -y install \ + git \ + wget \ + unzip \ + && yum -q clean packages + +# 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}" diff --git a/lazy-ci/package/fpm.sh b/lazy-ci/package/fpm.sh new file mode 100755 index 0000000..66d72ed --- /dev/null +++ b/lazy-ci/package/fpm.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..." diff --git a/lazy-ci/publish/repo.sh b/lazy-ci/publish/repo.sh new file mode 100755 index 0000000..66d72ed --- /dev/null +++ b/lazy-ci/publish/repo.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..." diff --git a/lazy-ci/test/jmeter.sh b/lazy-ci/test/jmeter.sh new file mode 100755 index 0000000..66d72ed --- /dev/null +++ b/lazy-ci/test/jmeter.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..." diff --git a/lazy-ci/test/junit.sh b/lazy-ci/test/junit.sh new file mode 100755 index 0000000..66d72ed --- /dev/null +++ b/lazy-ci/test/junit.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..." diff --git a/lazy-ci/ubuntu-16.Dockerfile b/lazy-ci/ubuntu-16.Dockerfile new file mode 100644 index 0000000..ed7b9c1 --- /dev/null +++ b/lazy-ci/ubuntu-16.Dockerfile @@ -0,0 +1,23 @@ +# 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}" diff --git a/lazy-ci/validate/fourth-a.sh b/lazy-ci/validate/fourth-a.sh new file mode 100755 index 0000000..fdba0eb --- /dev/null +++ b/lazy-ci/validate/fourth-a.sh @@ -0,0 +1,19 @@ +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..." diff --git a/lazy-ci/validate/fourth-b.sh b/lazy-ci/validate/fourth-b.sh new file mode 100755 index 0000000..fdba0eb --- /dev/null +++ b/lazy-ci/validate/fourth-b.sh @@ -0,0 +1,19 @@ +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..." diff --git a/lazy-ci/validate/third.sh b/lazy-ci/validate/third.sh new file mode 100755 index 0000000..66d72ed --- /dev/null +++ b/lazy-ci/validate/third.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# 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. + +echo "Start ${0} script..." +echo "Stop ${0} script..."