Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build procedure and deployment pipeline for Ubuntu 20.04 #202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ pipeline {
}

stage('Setup and build') {
agent { label 'ubuntu && 16.04 && php7.4' }
agent { label 'ubuntu && 20.04 && php7.4' }
environment {
GIT_SHORT_COMMIT = build.shortCommitRef()
ARTIFACT_VERSION = "${env.PIPELINE_VERSION}" + '+sha.' + "${env.GIT_SHORT_COMMIT}"
GIT_SHORT_COMMIT = build.shortCommitRef()
ARTIFACT_VERSION = "${env.PIPELINE_VERSION}" + '+sha.' + "${env.GIT_SHORT_COMMIT}"
}
stages {
stage('Setup') {
Expand Down Expand Up @@ -72,54 +72,54 @@ pipeline {
}

stage('Deploy to acceptance') {
agent any
agent { label 'ubuntu && 20.04' }
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'acceptance'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'udb3-web-acc02'
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
triggerDeployment nodeName: 'uitdatabank-web-acc01'
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${util.getJobDisplayName()} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
}
}

stage('Deploy to testing') {
input { message "Deploy to Testing?" }
agent any
agent { label 'ubuntu && 20.04' }
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'testing'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'udb3-web-test03'
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
triggerDeployment nodeName: 'uitdatabank-web-test01'
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${util.getJobDisplayName()} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
}
}

stage('Deploy to production') {
input { message "Deploy to Production?" }
agent any
agent { label 'ubuntu && 20.04' }
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'production'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'udb3-web-prod03'
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
triggerDeployment nodeName: 'uitdatabank-web-prod01'
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${util.getJobDisplayName()} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
cleanup {
cleanupAptlySnapshots repository: env.REPOSITORY_NAME
Expand All @@ -128,7 +128,7 @@ pipeline {
}

stage('Tag release') {
agent { label 'ubuntu && 16.04' }
agent any
steps {
copyArtifacts filter: 'pkg/*.deb', projectName: env.JOB_NAME, flatten: true, selector: specific(env.BUILD_NUMBER)
tagRelease commitHash: artifact.metadata(artifactFilter: '*.deb', field: 'git-ref')
Expand Down
5 changes: 4 additions & 1 deletion lib/tasks/build.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
desc "Build binaries"
desc 'Build binaries'
task :build do |task|
system('composer2 install --no-dev --ignore-platform-reqs --prefer-dist --optimize-autoloader') or exit 1

FileUtils.rm('web/jwt-example.php', :force => true)
FileUtils.rm('config.dist.yml', :force => true)
 FileUtils.mkdir('log')
end
15 changes: 7 additions & 8 deletions lib/tasks/build_artifact.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
desc "Create a debian package from the binaries."
desc 'Create a debian package from the binaries.'
task :build_artifact do |task|

calver_version = ENV['PIPELINE_VERSION'].nil? ? Time.now.strftime("%Y.%m.%d.%H%M%S") : ENV['PIPELINE_VERSION']
Expand All @@ -8,25 +8,24 @@ task :build_artifact do |task|
vendor = 'publiq VZW'
maintainer = 'Infra publiq <infra@publiq.be>'
license = 'Apache-2.0'
description = 'JSON Web Token provider (via Auth0) for UiTDatabank 3'
description = 'JSON Web Token provider for UiTdatabank'
source = 'https://github.com/cultuurnet/jwt-provider'
build_url = ENV['JOB_DISPLAY_URL'].nil? ? "" : ENV['JOB_DISPLAY_URL']
build_url = ENV['JOB_DISPLAY_URL'].nil? ? '' : ENV['JOB_DISPLAY_URL']

basedir = '/var/www/udb3-jwt-provider'
basedir = '/var/www/jwt-provider'

FileUtils.mkdir_p('pkg')
FileUtils.touch('config.yml')

system("fpm -s dir -t deb -n #{artifact_name} -v #{version} -a all -p pkg \
-x '.git*' -x pkg -x config.dist.yml -x 'Gemfile*' -x Jenkinsfile -x .bundle -x vendor/bundle \
--config-files #{basedir}/config.yml \
--prefix #{basedir} \
-x '.git*' -x pkg -x 'Gemfile*' -x Jenkinsfile -x .bundle -x vendor/bundle \
--prefix #{basedir} --config-files #{basedir}/config.yml \
--deb-user www-data --deb-group www-data \
--description '#{description}' --url '#{source}' --vendor '#{vendor}' \
--license '#{license}' -m '#{maintainer}' \
--deb-field 'Pipeline-Version: #{calver_version}' \
--deb-field 'Git-Ref: #{git_short_ref}' \
--deb-field 'Build-Url: #{build_url}' \
--deb-field 'Git-Ref: #{git_short_ref}' \
."
) or exit 1

Expand Down
Loading