Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
ci-testing
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bo-Chun Chen
ci-testing
Commits
6d92344a
Commit
6d92344a
authored
4 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Init commit
parents
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Jenkinsfile
+71
-0
71 additions, 0 deletions
Jenkinsfile
build.yaml
+18
-0
18 additions, 0 deletions
build.yaml
test-build.json
+35
-0
35 additions, 0 deletions
test-build.json
with
124 additions
and
0 deletions
Jenkinsfile
0 → 100644
+
71
−
0
View file @
6d92344a
pipeline
{
agent
none
options
{
gitlabBuilds
(
builds:
[
'Linting'
,
'Build image'
])
}
stages
{
stage
(
'Linting'
)
{
agent
{
docker
{
image
'cytopia/ansible-lint'
args
'--entrypoint= '
}
}
steps
{
script
{
try
{
sh
'ansible-lint build.yaml'
}
catch
(
err
)
{
echo
err
.
getMessage
()
unstable
(
'Linting failed'
)
}
}
}
post
{
success
{
updateGitlabCommitStatus
name:
'Linting'
,
state:
'success'
}
unstable
{
updateGitlabCommitStatus
name:
'Linting'
,
state:
'failed'
}
}
}
stage
(
'Build image'
)
{
agent
{
docker
{
image
'gitlab.rc.uab.edu:4567/louistw/utility:v0.1'
args
'-u root:root -v /var/jenkins_home/.ssh:/root/.ssh --add-host=ruffner.rc.uab.edu:192.168.16.10'
}
}
environment
{
GIT_COMMIT
=
sh
(
returnStdout:
true
,
script:
'git rev-parse --short $GIT_COMMIT'
).
trim
()
APP_CRED
=
credentials
(
'uab-dev-openrc'
)
}
steps
{
sh
'''
echo "hosts: files dns" > /etc/nsswitch.conf
. ${APP_CRED}
floatingip=(`openstack floating ip create -c id -c floating_ip_address -f value bright-external-flat-externalnet`)
read -r FLOATING_IP FLOATING_IP_ID <<< ${floatingip[@]}
packer build --var "build_version=$GIT_COMMIT" \
--var "ssh_host=$FLOATING_IP" \
--var "floating_ip=$FLOATING_IP_ID" \
test-build.json
openstack floating ip delete $FLOATING_IP_ID
'''
}
post
{
success
{
updateGitlabCommitStatus
name:
'Build image'
,
state:
'success'
echo
'build ood image success'
}
failure
{
updateGitlabCommitStatus
name:
'Build image'
,
state:
'failed'
echo
'build ood image failed'
}
}
}
}
}
This diff is collapsed.
Click to expand it.
build.yaml
0 → 100644
+
18
−
0
View file @
6d92344a
---
-
hosts
:
localhost
tasks
:
-
name
:
Install pip
yum
:
name
:
-
yum-utils
-
python-pip
-
vim
-
name
:
Create file at /root
copy
:
content
:
"
build
completed"
dest
:
"
/root/build-result"
-
name
:
Verify build
debug
:
msg
:
"
{{
lookup('file',
'/root/build-result')
}}"
This diff is collapsed.
Click to expand it.
test-build.json
0 → 100644
+
35
−
0
View file @
6d92344a
{
"builders"
:[
{
"type"
:
"openstack"
,
"image_name"
:
"testbuild-{{user `build_version`}}"
,
"source_image_name"
:
"CentOS-7-x86_64-GenericCloud-1905"
,
"flavor"
:
"m1.medium"
,
"floating_ip"
:
"{{ user `floating_ip` }}"
,
"networks"
:
[
"913c4b31-f101-4cfc-8648-28e214ddee16"
],
"instance_floating_ip_net"
:
"913c4b31-f101-4cfc-8648-28e214ddee16"
,
"ssh_host"
:
"{{ user `ssh_host` }}"
,
"ssh_username"
:
"centos"
,
"ssh_keypair_name"
:
"jenkins-keypair"
,
"ssh_private_key_file"
:
"/root/.ssh/id_rsa"
,
"reuse_ips"
:
true
}
],
"provisioners"
:
[
{
"type"
:
"shell"
,
"inline"
:
[
"sudo yum install -y epel-release"
,
"sudo yum install -y ansible git vim bash-completion"
,
"sudo yum install -y NetworkManager"
,
"sudo systemctl restart NetworkManager"
,
"sudo nmcli con mod 'Wired connection 1' connection.id 'eth1'"
]
},
{
"type"
:
"ansible-local"
,
"playbook_file"
:
"./build.yaml"
,
"extra_arguments"
:
[
"-b"
]
}
]
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment