Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
maven_test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
郭灿峰
maven_test
Commits
ee07747f
Commit
ee07747f
authored
Jul 08, 2020
by
郭灿峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Jenkinsfile
parent
70b656c1
Pipeline
#25
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
30 deletions
+40
-30
Jenkinsfile
Jenkinsfile
+40
-30
No files found.
Jenkinsfile
View file @
ee07747f
pipeline
{
agent
any
environment
{
commit_id
=
get_commit_id
()
}
stages
{
stage
(
'Build'
)
{
steps
{
sh
'$(echo ${GIT_COMMIT} | cut -c 1-8)'
//sh '/var/jenkins_home/plugins/apache-maven-3.6.3/bin/mvn clean package'
sh
'/var/jenkins_home/plugins/apache-maven-3.6.3/bin/mvn clean package'
}
}
stage
(
'Build image'
)
{
steps
{
sh
'docker build -t registry.lizhi.co/registry/pybbs:${COMMIT_ID} .'
sh
'docker push registry.lizhi.co/registry/pybbs:${COMMIT_ID}'
}
}
stage
(
'deploy'
)
{
steps
{
sh
'sed -i "s#registry/pybbs#registry/pybbs:${COMMIT_ID}#g" docker-compose.yml'
sshPublisher
(
publishers:
[
sshPublisherDesc
(
configName:
'nginx'
,
transfers:
[
sshTransfer
(
cleanRemote:
false
,
execCommand:
'cd /app && docker-compose down &&docker-compose up -d'
,
remoteDirectory:
'/app'
,
removePrefix:
''
,
sourceFiles:
'docker-compose.yml'
)
],
verbose:
true
)
]
)
}
}
// stage('Build image') {
// steps {
// sh 'docker build -t registry.lizhi.co/registry/pybbs:${GIT_COMMIT} .'
// sh 'docker push registry.lizhi.co/registry/pybbs:${GIT_COMMIT}'
// }
// }
// stage('deploy') {
// steps {
// sh 'sed -i "s#registry/pybbs#registry/pybbs:${GIT_COMMIT}#g" docker-compose.yml'
// sshPublisher(
// publishers: [
// sshPublisherDesc(
// configName: 'nginx',
// transfers: [
// sshTransfer(
// cleanRemote: false,
// execCommand: 'cd /app && docker-compose down &&docker-compose up -d',
// remoteDirectory: '/app',
// removePrefix: '',
// sourceFiles: 'docker-compose.yml'
// )
// ],
// verbose: true
// )
// ]
// )
// }
// }
}
}
def
get_commit_id
()
{
node
(
'master'
)
{
if
(
env
.
GIT_COMMIT
)
{
return
GIT_COMMIT
.
substring
(
0
,
6
)
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment