Skip to content

Commit 6f522d8

Browse files
committed
Update build configuration for Ubuntu 20.04
1 parent ee27579 commit 6f522d8

File tree

5 files changed

+50
-51
lines changed

5 files changed

+50
-51
lines changed

Jenkinsfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pipeline {
1515
}
1616

1717
stage('Setup and build') {
18-
agent { label 'ubuntu && 16.04 && php7.1' }
18+
agent { label 'ubuntu && 20.04 && php7.4' }
1919
environment {
2020
GIT_SHORT_COMMIT = build.shortCommitRef()
2121
ARTIFACT_VERSION = "${env.PIPELINE_VERSION}" + '+sha.' + "${env.GIT_SHORT_COMMIT}"
@@ -28,12 +28,12 @@ pipeline {
2828
}
2929
stage('Build') {
3030
steps {
31-
sh label: 'Build binaries', script: 'bundle exec rake projectaanvraag-api:build'
31+
sh label: 'Build binaries', script: 'bundle exec rake build'
3232
}
3333
}
3434
stage('Build artifact') {
3535
steps {
36-
sh label: 'Build artifact', script: "bundle exec rake projectaanvraag-api:build_artifact ARTIFACT_VERSION=${env.ARTIFACT_VERSION}"
36+
sh label: 'Build artifact', script: "bundle exec rake build_artifact ARTIFACT_VERSION=${env.ARTIFACT_VERSION}"
3737
archiveArtifacts artifacts: "pkg/*${env.ARTIFACT_VERSION}*.deb", onlyIfSuccessful: true
3838
}
3939
}
@@ -61,24 +61,24 @@ pipeline {
6161
}
6262

6363
stage('Deploy to development') {
64-
agent any
64+
agent { label 'ubuntu && 20.04' }
6565
options { skipDefaultCheckout() }
6666
environment {
6767
APPLICATION_ENVIRONMENT = 'development'
6868
}
6969
steps {
70-
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
70+
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
7171
}
7272
}
7373

7474
stage('Deploy to testing') {
75-
agent any
75+
agent { label 'ubuntu && 20.04' }
7676
options { skipDefaultCheckout() }
7777
environment {
7878
APPLICATION_ENVIRONMENT = 'testing'
7979
}
8080
steps {
81-
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
81+
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
8282
triggerDeployment nodeName: 'projectaanvraag-web-test02'
8383
}
8484
post {
@@ -90,13 +90,13 @@ pipeline {
9090

9191
stage('Deploy to production') {
9292
input { message "Deploy to Production?" }
93-
agent any
93+
agent { label 'ubuntu && 20.04' }
9494
options { skipDefaultCheckout() }
9595
environment {
9696
APPLICATION_ENVIRONMENT = 'production'
9797
}
9898
steps {
99-
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
99+
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
100100
triggerDeployment nodeName: 'projectaanvraag-web-prod02'
101101
}
102102
post {
@@ -110,7 +110,7 @@ pipeline {
110110
}
111111

112112
stage('Tag release') {
113-
agent { label 'ubuntu && 16.04' }
113+
agent any
114114
steps {
115115
copyArtifacts filter: 'pkg/*.deb', projectName: env.JOB_NAME, flatten: true, selector: specific(env.BUILD_NUMBER)
116116
tagRelease commitHash: artifact.metadata(artifactFilter: '*.deb', field: 'git-ref')

lib/tasks/build.rake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
desc "Build binaries"
2+
task :build do |task|
3+
system('composer install --no-dev --ignore-platform-reqs --optimize-autoloader --no-interaction') or exit 1
4+
end

lib/tasks/build_artifact.rake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
desc "Create a debian package from the binaries."
2+
task :build_artifact do |task|
3+
4+
calver_version = ENV['PIPELINE_VERSION'].nil? ? Time.now.strftime("%Y.%m.%d.%H%M%S") : ENV['PIPELINE_VERSION']
5+
git_short_ref = `git rev-parse --short HEAD`.strip
6+
version = ENV['ARTIFACT_VERSION'].nil? ? "#{calver_version}+sha.#{git_short_ref}" : ENV['ARTIFACT_VERSION']
7+
artifact_name = 'projectaanvraag-api'
8+
vendor = 'publiq VZW'
9+
maintainer = 'Infra publiq <infra@publiq.be>'
10+
license = 'Apache-2.0'
11+
description = 'Projectaanvraag API'
12+
build_url = ENV['JOB_DISPLAY_URL'].nil? ? '' : ENV['JOB_DISPLAY_URL']
13+
source = 'https://github.com/cultuurnet/projectaanvraag-silex/'
14+
15+
FileUtils.mkdir_p('pkg')
16+
FileUtils.mkdir_p('cache')
17+
FileUtils.mkdir_p('log')
18+
FileUtils.touch('config.yml')
19+
FileUtils.touch('user_roles.yml')
20+
FileUtils.touch('integration_types.yml')
21+
22+
system("fpm -s dir -t deb -n #{artifact_name} -v #{version} -a all -p pkg \
23+
--prefix /var/www/projectaanvraag-api \
24+
-x '.git*' -x pkg -x '*.dist.yml' -x Jenkinsfile \
25+
--config-files /var/www/projectaanvraag-api/config.yml \
26+
--config-files /var/www/projectaanvraag-api/user_roles.yml \
27+
--config-files /var/www/projectaanvraag-api/integration_types.yml \
28+
--deb-user www-data --deb-group www-data \
29+
--description '#{description}' --url '#{source}' --vendor '#{vendor}' \
30+
--license '#{license}' -m '#{maintainer}' \
31+
--deb-field 'Pipeline-Version: #{calver_version}' \
32+
--deb-field 'Build-Url: #{build_url}' \
33+
--deb-field 'Git-Ref: #{git_short_ref}' \
34+
."
35+
) or exit 1
36+
end

lib/tasks/projectaanvraag-api/build.rake

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/tasks/projectaanvraag-api/build_artifact.rake

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)