►
From YouTube: Triggering Pipeline when Draft Prefix is Removed
Description
Using GitLab's Webhook Payload, this is an easy way to use a CI Pipeline to trigger pipeline when the Draft prefix is removed.
Sample Project: https://gitlab.com/gitlab-gold/tpoffenbarger/mr-rename-pipeline
https://docs.gitlab.com/ee/ci/triggers/#using-webhook-payload-in-the-triggered-pipeline
A
Hi,
my
name
is
tim
poffenberger
and
I
am
a
solutions
architect
at
get
lab
and
wanted
to
walk
through
a
way
around
a
particular
capability
that
has
been
requested,
but
we
are
still
working
on
developing
and
and
it's
as
such
often
times,
especially
within
our
new
ways
of
running
pipelines.
You
might
want
to
while
a
project
or
a
merge
request
is
in
draft
mode,
have
a
certain
set
of
ci
jobs
run
and
then
once
it
once
that
draft
or
work
in
progress
mode
is
removed
within
the
title.
A
Prefix
of
that
merge
request
have
subsequent
jobs
run
to
ensure
that
the
longer
running
jobs
are
only
reserved
until
after
that
draft
work
is,
is
completed.
So
here's
an
issue.
That's
that's
been
created.
That
kind
of
outlines
pretty
nicely
what
is
what's
being
requested
here,
there's
another
one
that
you
know
allows
users
to
toggle
jobs
on
merge
requests
while
they're
in
draft
mode,
so
something
that's
a
little
bit
more
dynamic
and
there's
a
short
through
that.
A
I
would
encourage
you
watching
just
to
see
what
this
could
potentially
look
like
and
then
more
specifically,
our
dynamic
analysis
or
dashed
jobs
sometimes
take
a
little
bit
of
time.
So
thinking
through
what
would
this
look
like
to
to
actually
build
out
a
capability
that
would
be
driven
more
towards
some
of
our
very
specific
types
of
jobs
within
a
ci
pipeline?
A
Well,
there
was
a
new
feature
that
was
rolled
out
in
13.11,
where
the
feature
flag
was
removed.
That
made
me
start
thinking,
hey
that
we
can
do
this
without
necessarily
building
out
any
additional
capabilities
within
the
prod
product,
specifically
within
our
web
hook
capability
when
you,
when
a
web
hook
page
or
when
a
web
hook
triggers
a
pipeline
that
payload
of
the
web
hook
so
there's
a
json
file
that
is
is
transmitted
as
data
is
actually
available
within
the
ci
pipeline.
A
So
here's
an
example
of
a
particular
project.
There's
a
there's,
a
working
or
a
draft,
a
a
merge
request
in
draft
mode
currently-
and
you
can
see
that
within
here
I
actually
have
a
quick
job
that
I
only
want
you
know
running.
A
I
want
it
to
run
all
the
time,
but
the
long
running
job
it's
going
to
take
120
seconds,
and
I
don't
want
my
pipeline
to
take
that
long.
So
I
really
just
want
this
to
to
run
only
when
this
draft
is
not
included
in
that
merge
request.
Well.
In
order
to
do
that,
I
would
have
to
mark
this
as
ready
and
then
manually
kick
off
another
pipeline,
which
is
what
I
want
to
avoid.
I
want
the
second.
A
A
Additionally,
I'm
creating
a
project
access
token,
which
is
going
to
be
stored
here
and
I'll,
go
ahead
and
store
this
in
my
ci
variables.
So
we
can
actually
see
that
there's
a
project
token
in
my
ci
variables
and
then
now
I'm
going
to
show
you
kind
of
the
the
heart
of
what's
going
to
happen
here.
A
Here's
a
particular
docker
image
that
has
both
curl
and
jq,
which
parses
json
and
allows
you
to
kind
of
query
for
certain
things,
and
what
I'm
going
to
do
is
I'm
going
to
export
that
trigger
payload
and
I'm
going
to
grab
the
source
branch.
The
previous
commit
title
and
or
the
previous
merge
request
title
the
current
merge
request
title
and
then
the
merge
request,
iid
and
then
within
this
draft
job.
A
I'm
going
to
look
for
the
presence
of
draft
in
the
previous
merge
request
event,
and
then
I'm
going
to
look
for
the
the
lack
of
existence
of
draft
in
the
current
merge
request
title
and
then,
if
both
of
those
things
pass,
I'm
not
going
to
exit
and
I'm
like
proceed
to
this
curl
call,
which
is
then
going
to
trigger
a
draft
mode
pipe
or
a
a
pipeline,
and
you
can
actually
see
if
I
refresh
this
page.
A
That
is
exactly
what
has
happened.
You
can
see
that
this
merger
merged
result
pipeline
got
kicked
off
and
we
have
this
long
running
job
and
all
happened
behind
the
scenes.
Once
I
marked
that
as
draft
and
the
the
secret
behind
this
is.
This
job
is
running
on
this,
mr
web,
hooks
branch,
which
is
also
leveraged
within
here.
So
you
can
actually
see
that
I'm
referencing
the
mr
web
hooks
in
this
branch
within
the
web
hook
when
I
set
that
up
and
then.
A
What
happened
here
was
this
will
always
get
evaluated
when
any
change
to
a
merge
request
happens,
but
it
will
only
trigger
this
merge
request
pipeline
when
those
two
conditions
match
specifically
when
the
draft
was
previously
there
and
is
no
longer
there.
That's
it.
It's
a
pretty
handy
feature
looking
forward
to
having
this
built
right
into
the
product,
but
until
then
here's
a
pretty
elegant
solution
to
solve
this
need.