Skip to content
Snippets Groups Projects
Commit 8265fe64 authored by Walter Lozano's avatar Walter Lozano Committed by Dylan Aïssi
Browse files

Move obs copy logic to script


To make it easier to read and to avoid code duplication move the obs copy
logic to its own script, following the same approach of other release
scripts.

Signed-off-by: default avatarWalter Lozano <walter.lozano@collabora.com>
parent 4794f8da
No related branches found
No related tags found
1 merge request!190Improvements to folding pipeline (3)
Pipeline #757532 passed with warnings
......@@ -184,30 +184,9 @@ obs-repository-copy:
- apt update && apt install -y --no-install-recommends ca-certificates osc sed
script:
- |
case "$NEXT_RELEASE" in
*dev*|*pre)
DEV_RELEASE=1
;;
*)
if [ -z "$PREV_STABLE_RELEASE" ]; then
echo "No PREV_STABLE_RELEASE specified. Aborting!!!"
echo "Please specify a valid previous stable release via the PREV_STABLE_RELEASE variable in pipeline run"
exit 1
fi
;;
esac
- if [ "$NOACT" -ne 1 ]; then RUN=""; fi
- |
for comp in $COMPONENTS
do
# Temporary disable builds during the copy to avoid useless rebuild
# until 'rebuild="local" block="never"' is defined in the new repo $NEXT_RELEASE
$RUN osc api -X POST "/source/$OSNAME:$RELEASE:$comp?cmd=set_flag&flag=build&status=disable&user=Admin"
$RUN osc api -X POST "/source/$OSNAME:$NEXT_RELEASE:$comp?cmd=copy&oproject=$OSNAME:$RELEASE:$comp&comment=Branch%20release%20$NEXT_RELEASE%20from%20$RELEASE&user=Admin&withbinaries=1"
sleep 15
done
- ./release-scripts/branch-obs obs-repository-copy
- |
cat <<EOF
👷 Commands to be run on OBS Backend Server:
......@@ -228,24 +207,7 @@ obs-repository-copy-check:
- obs-repository-copy
script:
- apt update && apt install -y --no-install-recommends ca-certificates osc sed
- |
case "$NEXT_RELEASE" in
*dev*|*pre)
DEV_RELEASE=1
;;
esac
- if [ "$NOACT" -ne 1 ]; then RUN=""; fi
- |
for comp in $COMPONENTS
do
## This step is required to ensure that the project copy has been completed
# For project meta config
$RUN osc meta prj $OSNAME:$NEXT_RELEASE:$comp > osc_meta.txt
$RUN cat osc_meta.txt
# For project config
$RUN osc meta prjconf $OSNAME:$NEXT_RELEASE:$comp > osc_meta.txt
$RUN cat osc_meta.txt
done
- ./release-scripts/branch-obs obs-repository-copy-check
obs-prjconf-update:
extends: .custom_globals_manual
......@@ -254,44 +216,7 @@ obs-prjconf-update:
- obs-repository-copy-check
script:
- apt update && apt install -y --no-install-recommends ca-certificates osc sed
- |
case "$NEXT_RELEASE" in
*dev*|*pre)
DEV_RELEASE=1
;;
esac
- if [ "$NOACT" -ne 1 ]; then RUN=""; fi
- |
for comp in $COMPONENTS
do
## This step is required to ensure all settings are copied from the previous release
# Restore build flag to enable, it was disabled during obs-repository-copy
# to avoid useless rebuild due to the missing 'rebuild="local" block="never"'
$RUN osc api -X POST "/source/$OSNAME:$RELEASE:$comp?cmd=set_flag&flag=build&status=enable&user=Admin"
# For project meta config
$RUN osc meta prj $OSNAME:$RELEASE:$comp | sed "s/$RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prj $OSNAME:$NEXT_RELEASE:$comp -F osc_meta.txt
# For project config
$RUN osc meta prjconf $OSNAME:$RELEASE:$comp | sed "s/$RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prjconf $OSNAME:$NEXT_RELEASE:$comp -F osc_meta.txt
if [ $DEV_RELEASE -ne 1 ]
then
for chan in $CHANNELS
do
# For project meta config
$RUN osc meta prj $OSNAME:$PREV_STABLE_RELEASE:$chan:$comp | sed "s/$PREV_STABLE_RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prj $OSNAME:$NEXT_RELEASE:$chan:$comp -F osc_meta.txt
# For project config
$RUN osc meta prjconf $OSNAME:$PREV_STABLE_RELEASE:$chan:$comp | sed "s/$PREV_STABLE_RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prjconf $OSNAME:$NEXT_RELEASE:$chan:$comp -F osc_meta.txt
done
fi
done
- ./release-scripts/branch-obs obs-prjconf-update
obs-service-restart:
extends: .custom_globals_manual
......@@ -320,27 +245,7 @@ obs-finish-server:
- obs-service-restart
before_script: []
script:
- |
case "$NEXT_RELEASE" in
*dev*|*pre)
DEV_RELEASE=1
;;
esac
- if [ "$NOACT" -ne 1 ]; then RUN=""; fi
- cd release-scripts
- |
echo "👷 Commands to be run on OBS Backend Server"
for comp in $COMPONENTS
do
echo "obs_admin --republish-repository $OSNAME:$NEXT_RELEASE:$comp default"
if [ $DEV_RELEASE -ne 1 ]
then
for chan in $CHANNELS
do
echo "obs_admin --republish-repository $OSNAME:$NEXT_RELEASE:$chan:$comp default"
done
fi
done
- ./release-scripts/branch-obs obs-finish-server
- |
cat <<EOF
▶️ Once the above commands have been executed, manually trigger the next job
......@@ -354,13 +259,7 @@ obs-complete:
before_script:
- apt update && apt install -y --no-install-recommends ca-certificates osc
script:
- if [ "$NOACT" -ne 1 ]; then RUN=""; fi
- |
echo Check that the OBS projects have been created:
for comp in $COMPONENTS
do
$RUN osc prjresults $OSNAME:$NEXT_RELEASE:$comp --vertical
done
- ./release-scripts/branch-obs obs-complete
base-files-trigger:
extends: .custom_globals_manual
......
......@@ -3,8 +3,6 @@ variables:
COMPONENTS: "development target sdk non-free"
CHANNELS: "security updates backports"
ADDON_BRANCHES: "security updates"
RUN: "echo +++"
DEV_RELEASE: 0
# The following variables are kept here since Gitlab prefilled variables
# are only used in manual jobs, see .gitlab-ci.yml
PURPOSE: testing
......
#!/bin/bash
set -e
DRY_RUN=0
RUN=
check-env(){
if [ -z "$CHANNELS" ]
then
echo "No CHANNELS specified, using default"
CHANNELS="security updates backports"
fi
if [ -z "$COMPONENTS" ]
then
echo "No COMPONENTS specified, using default"
COMPONENTS="development target sdk non-free"
fi
[ -z "$OSNAME" ] && (echo "No OS name specified, use OSNAME env var to specify it" >&2; exit 1)
[ -z "$RELEASE" ] && (echo "No release specified, use RELEASE env var to specify it" >&2; exit 1)
case "$NEXT_RELEASE" in
*dev*|*pre)
DEV_RELEASE=1
;;
*)
if [ -z "$PREV_STABLE_RELEASE" ]
then
echo "No PREV_STABLE_RELEASE specified. Aborting!!!"
echo "Please specify a valid previous stable release via the PREV_STABLE_RELEASE variable in pipeline run"
exit 1
fi
;;
esac
return 0
}
obs-repository-copy(){
for comp in $COMPONENTS
do
# Temporary disable builds during the copy to avoid useless rebuild
# until 'rebuild="local" block="never"' is defined in the new repo $NEXT_RELEASE
$RUN osc api -X POST "/source/$OSNAME:$RELEASE:$comp?cmd=set_flag&flag=build&status=disable&user=Admin"
$RUN osc api -X POST "/source/$OSNAME:$NEXT_RELEASE:$comp?cmd=copy&oproject=$OSNAME:$RELEASE:$comp&comment=Branch%20release%20$NEXT_RELEASE%20from%20$RELEASE&user=Admin&withbinaries=1"
sleep 15
done
}
obs-repository-copy-check(){
for comp in $COMPONENTS
do
## This step is required to ensure that the project copy has been completed
# For project meta config
$RUN osc meta prj $OSNAME:$NEXT_RELEASE:$comp > osc_meta.txt
$RUN cat osc_meta.txt
# For project config
$RUN osc meta prjconf $OSNAME:$NEXT_RELEASE:$comp > osc_meta.txt
$RUN cat osc_meta.txt
done
}
obs-prjconf-update(){
for comp in $COMPONENTS
do
## This step is required to ensure all settings are copied from the previous release
# Restore build flag to enable, it was disabled during obs-repository-copy
# to avoid useless rebuild due to the missing 'rebuild="local" block="never"'
$RUN osc api -X POST "/source/$OSNAME:$RELEASE:$comp?cmd=set_flag&flag=build&status=enable&user=Admin"
# For project meta config
$RUN osc meta prj $OSNAME:$RELEASE:$comp | sed "s/$RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prj $OSNAME:$NEXT_RELEASE:$comp -F osc_meta.txt
# For project config
$RUN osc meta prjconf $OSNAME:$RELEASE:$comp | sed "s/$RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prjconf $OSNAME:$NEXT_RELEASE:$comp -F osc_meta.txt
if [ $DEV_RELEASE -ne 1 ]
then
for chan in $CHANNELS
do
# For project meta config
$RUN osc meta prj $OSNAME:$PREV_STABLE_RELEASE:$chan:$comp | sed "s/$PREV_STABLE_RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prj $OSNAME:$NEXT_RELEASE:$chan:$comp -F osc_meta.txt
# For project config
$RUN osc meta prjconf $OSNAME:$PREV_STABLE_RELEASE:$chan:$comp | sed "s/$PREV_STABLE_RELEASE/$NEXT_RELEASE/g" > osc_meta.txt
$RUN cat osc_meta.txt
$RUN osc meta prjconf $OSNAME:$NEXT_RELEASE:$chan:$comp -F osc_meta.txt
done
fi
done
}
obs-finish-server(){
echo "👷 Commands to be run on OBS Backend Server"
for comp in $COMPONENTS
do
echo "obs_admin --republish-repository $OSNAME:$NEXT_RELEASE:$comp default"
if [ $DEV_RELEASE -ne 1 ]
then
for chan in $CHANNELS
do
echo "obs_admin --republish-repository $OSNAME:$NEXT_RELEASE:$chan:$comp default"
done
fi
done
}
obs-complete(){
echo Check that the OBS projects have been created:
for comp in $COMPONENTS
do
$RUN osc prjresults $OSNAME:$NEXT_RELEASE:$comp --vertical
done
}
check-env
#If the env var NOACT = 1 set dry run mode
if [ "${NOACT}" = "1" ]
then
DRY_RUN=1
fi
while getopts 'dg:nr:' opt
do
case "$opt" in
d|n)
DRY_RUN=1
;;
esac
done
shift "$(($OPTIND -1))"
if [ "${DRY_RUN}" = "1" ]
then
RUN="echo +++"
echo "Dry run: not modifying anything!"
fi
case "$1" in
obs-repository-copy)
obs-repository-copy
;;
obs-repository-copy-check)
obs-repository-copy-check
;;
obs-prjconf-update)
obs-prjconf-update
;;
obs-finish-server)
obs-finish-server
;;
obs-complete)
obs-complete
;;
*)
echo Invalid command
exit 1
esac
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment