diff --git a/Jenkinsfile b/Jenkinsfile index cc6654f..d044a7f 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,7 +49,8 @@ $class: 'GitSCMSource', remote: libCustom.remote, credentialsId: libCustom.credentialsId - ]) + ]), + changelog: false, ) // Define the remotes and the working and deploy branches @@ -75,7 +77,7 @@ ], inLabels: [ 'ubuntu-16', 'centos-7' ], onLabels: [ default: 'master', docker: 'docker', mac: 'mac', android: 'android', ], - noPoll: "(.+_.+)", // Don't poll or automatically trigger private branches + noIndex: "(${releaseBranch}|.+_.+)", // Avoid automatic indexing for release and private branches ) lazyStage { @@ -84,18 +86,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: { echo "This is my second task" }, in: '*', on: 'docker' ], [ 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' ], - ] +*/ ] } lazyStage { @@ -126,18 +131,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 +188,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 +216,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 +233,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: '*',