Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
471728f8
Commit
471728f8
authored
Mar 08, 2018
by
Achilleas Pipinellis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for the pipeline to start before canceling it
parent
95016507
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
scripts/trigger-build-docs
scripts/trigger-build-docs
+14
-5
No files found.
scripts/trigger-build-docs
View file @
471728f8
...
@@ -24,8 +24,8 @@ def docs_branch
...
@@ -24,8 +24,8 @@ def docs_branch
# The maximum string length a file can have on a filesystem (ext4)
# The maximum string length a file can have on a filesystem (ext4)
# is 63 characters. Let's use something smaller to be 100% sure.
# is 63 characters. Let's use something smaller to be 100% sure.
max
=
42
max
=
42
# Prefix the remote branch with
'preview-' in order to avoid
# Prefix the remote branch with
the slug of the project in order
# name conflicts in the rare case the branch name already
#
to avoid
name conflicts in the rare case the branch name already
# exists in the docs repo and truncate to max length.
# exists in the docs repo and truncate to max length.
"
#{
slug
}
-
#{
ENV
[
"CI_COMMIT_REF_SLUG"
]
}
"
[
0
...
max
]
"
#{
slug
}
-
#{
ENV
[
"CI_COMMIT_REF_SLUG"
]
}
"
[
0
...
max
]
end
end
...
@@ -41,12 +41,21 @@ def create_remote_branch
...
@@ -41,12 +41,21 @@ def create_remote_branch
Gitlab
.
create_branch
(
GITLAB_DOCS_REPO
,
docs_branch
,
'master'
)
Gitlab
.
create_branch
(
GITLAB_DOCS_REPO
,
docs_branch
,
'master'
)
puts
"=> Remote branch '
#{
docs_branch
}
' created"
puts
"=> Remote branch '
#{
docs_branch
}
' created"
# Get the latest pipeline ID which is also the first
pipelines
=
nil
pipeline_id
=
Gitlab
.
pipelines
(
GITLAB_DOCS_REPO
,
{
ref:
docs_branch
}).
last
.
id
# Wait until the pipeline is started
loop
do
sleep
1
puts
"=> Waiting for pipeline to start..."
pipelines
=
Gitlab
.
pipelines
(
GITLAB_DOCS_REPO
,
{
ref:
docs_branch
})
break
if
pipelines
.
any?
end
# Get the first pipeline ID which should be the only one for the branch
pipeline_id
=
pipelines
.
first
.
id
# Cancel the pipeline
# Cancel the pipeline
Gitlab
.
cancel_pipeline
(
GITLAB_DOCS_REPO
,
pipeline_id
)
Gitlab
.
cancel_pipeline
(
GITLAB_DOCS_REPO
,
pipeline_id
)
puts
"=> Canceled uneeded pipeline
#{
pipeline_id
}
for '
#{
docs_branch
}
'"
rescue
Gitlab
::
Error
::
BadRequest
rescue
Gitlab
::
Error
::
BadRequest
puts
"=> Remote branch '
#{
docs_branch
}
' already exists"
puts
"=> Remote branch '
#{
docs_branch
}
' already exists"
end
end
...
...
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