-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.gitlab-ci.yml
132 lines (122 loc) · 4.18 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
variables:
rh_22_release: '2-2-0'
librtl_version: '0.5.2-4'
namespace: rh.
stages:
- build
- deploy
.package: &package
image: ${docker_registry}${docker_rpm_repository}docker:latest-rpm
stage: build
tags:
- ca
- docker
before_script:
- safe_version=$(echo ${short_version} | tr -d -)
- safe_ref=$(echo ${CI_COMMIT_REF_NAME} | tr -d /| tr '[:upper:]' '[:lower:]')
- librtl_version="`echo ${librtl_version} | sed -r 's/\./-/g'`";
- if [ -z "$CI_COMMIT_TAG" ]; then
redhawk_version=${latest_version}
rpm_release="0.$CI_PIPELINE_ID.rh${safe_version}";
else
redhawk_version=${release_version}
rpm_release="`rpm --query --queryformat "%{release}\n" --specfile ${namespace}$CI_PROJECT_NAME.spec | head -n 1 | awk -F"." "{print $1}"`.rh${safe_version}";
fi
- redhawk_repo=$s3_repo_url/redhawk/cf-and-deps/yum/$redhawk_version/$dist/$arch
- librtl_repo=$s3_repo_url/redhawk-dependencies/librtlsdr/yum/$librtl_version/$dist/$arch
script:
- printf "FROM ${docker_registry}${rpmbuild_repository}rpmbuild:$dist-$arch-onbuild" > Dockerfile
- docker login ${docker_registry} -u ${docker_user} -p ${docker_password}
- docker image build --pull
--tag=$CI_PROJECT_PATH_SLUG-$safe_ref-$dist-$arch-rh${safe_version}
--build-arg "project=$CI_PROJECT_NAME"
--build-arg "rpm_release=$rpm_release"
--build-arg "spec_file=${namespace}$CI_PROJECT_NAME.spec"
--build-arg "arch=$arch"
--build-arg "other_repos=$redhawk_repo $librtl_repo" .
- id=$(docker container create $CI_PROJECT_PATH_SLUG-$safe_ref-$dist-$arch-rh${safe_version})
- docker container cp $id:/root/rpmbuild/RPMS/ output/
- docker container rm -f $id || true
- docker image rm -f $CI_PROJECT_PATH_SLUG-$safe_ref-$dist-$arch-rh${safe_version} || true
artifacts:
paths:
- output/*/*.rpm
expire_in: 2 days
except:
- master
- /^.*-external$/
- /^(\d+\.)?(\d+)?(\.\d+)$/
package:el6:rh2.2:
variables:
latest_version: 2.2-nightly
release_version: $rh_22_release
short_version: '2.2'
dist: el6
arch: x86_64
<<: *package
package:el6-i386:rh2.2:
variables:
latest_version: 2.2-nightly
release_version: $rh_22_release
short_version: '2.2'
dist: el6
arch: i686
<<: *package
package:el7:rh2.2:
variables:
latest_version: 2.2-nightly
release_version: $rh_22_release
short_version: '2.2'
dist: el7
arch: x86_64
<<: *package
deploy:
image: ${docker_registry}centos:7
stage: deploy
dependencies: []
script:
- if [ -n "$jenkins_url" ]; then
echo "Deploying to $jenkins_url/job/$CI_PROJECT_NAMESPACE/job/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME"
curl --insecure -X POST $jenkins_url/job/$CI_PROJECT_NAMESPACE/job/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME/buildWithParameters?pipeline_id=$CI_PIPELINE_ID --user $jenkins_user:$jenkins_api_token;
fi
except:
- master
- /^.*-external$/
- /^(\d+\.)?(\d+)?(\.\d+)$/
.s3: &s3
image: ${docker_registry}utils/s3cmd:el6-createrepo
stage: deploy
tags:
- s3
script:
- /usr/bin/s3cmd sync s3://$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/yum/$CI_COMMIT_REF_SLUG/rh${short_version}/$dist/$arch .
- mkdir -p $arch
- for file in `find output -name *.rpm`; do
cp $file $arch;
done
- repomanage --keep=2 --old $arch| xargs rm -f; createrepo --update $arch
- /usr/bin/s3cmd sync -F -v --delete-removed $arch s3://$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/yum/$CI_COMMIT_REF_SLUG/rh${short_version}/$dist/ && s3cmd setacl -v s3://$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/yum/$CI_COMMIT_REF_SLUG/rh${short_version}/$dist --acl-public --recursive || true
deploy-el7-2.2:
variables:
dist: el7
arch: x86_64
short_version: '2.2'
dependencies:
- package:el7:rh2.2
<<: *s3
deploy-el6-2.2:
variables:
dist: el6
arch: x86_64
short_version: '2.2'
dependencies:
- package:el6:rh2.2
<<: *s3
deploy-el6-i386-2.2:
variables:
dist: el6
arch: i686
short_version: '2.2'
dependencies:
- package:el6-i386:rh2.2
<<: *s3