Skip to content

Commit 84a2bb4

Browse files
committed
[I/Y-Build] Derive git branch and URL from job definition when cloning
This reduces hard-coded branch names in the pipeline file. It also avoids the need to update them, e.g. on maintenance branches respectively simplifies testing changes. Now one can either modify the git URL and branch-name in one place or they are derived if a modified copy of the build jobs is used, pointing to a fork of this repository and/or another branch. This also reduces the changes necessary during the preparation of a new development cycle. Furthermore this change minimizes the time the SSH-agent is running and unifies git-pushing.
1 parent cccd563 commit 84a2bb4

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

JenkinsJobs/Builds/build.jenkinsfile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,21 @@ spec:
7373
}
7474
}
7575
stage('Clone and tag Build Inputs') {
76+
environment {
77+
AGGREGATOR_LOCAL_BRANCH = "${scm.branches[0].name}"
78+
AGGREGATOR_REPOSITORY_URL = "${scm.userRemoteConfigs[0].url}" // http(s) URL expected
79+
}
7680
steps {
77-
sshagent (['github-bot-ssh']) {
81+
dir("${CJE_ROOT}/${AGG_DIR}") {
7882
sh '''#!/bin/bash -xe
7983
source $CJE_ROOT/buildproperties.shsource
8084

8185
git config --global user.email '[email protected]'
8286
git config --global user.name 'Eclipse Releng Bot'
8387

8488
# Clone this repo and all submodules into the 'AGG_DIR' directory
85-
git clone --branch=$BRANCH --recurse-submodules --remote-submodules \
86-
[email protected]:eclipse-platform/eclipse.platform.releng.aggregator.git "$CJE_ROOT/$AGG_DIR"
87-
88-
cd "$CJE_ROOT/$AGG_DIR"
89+
git clone --branch=${AGGREGATOR_LOCAL_BRANCH} --recurse-submodules --remote-submodules \
90+
${AGGREGATOR_REPOSITORY_URL} .
8991

9092
if [ -n "${GIT_SUBMODULE_BRANCHES}" ]; then
9193
for submodule in ${GIT_SUBMODULE_BRANCHES//,/ }; do
@@ -99,16 +101,10 @@ spec:
99101
fi
100102

101103
# Create 'Build input' commit (considering commits potentially submitted to the aggregator BRANCH in the meantime)
102-
git checkout $BRANCH
104+
git checkout ${AGGREGATOR_LOCAL_BRANCH}
103105
git pull
104106
git commit --all --message="Build input for build $BUILD_ID" || echo 'No submodule changes'
105-
106-
if [ "${BUILD_TYPE}" == "I" ]; then
107-
git push --verbose origin $BRANCH
108-
fi
109107
'''
110-
}
111-
dir("${CJE_ROOT}/${AGG_DIR}") {
112108
sshagent (['projects-storage.eclipse.org-bot-ssh']) {
113109
// Try to find the last tag of the current build type that is available as a promoted build
114110
// by checking the most recent 5 tags and seeing if an update site for it exists
@@ -138,14 +134,21 @@ spec:
138134
error('Abort scheduled build due to no changes')
139135
}
140136
}
141-
// Git tagging
137+
// Create git tags and push changes
142138
sshagent (['github-bot-ssh']) {
143139
sh '''#!/bin/bash -xe
144140
source $CJE_ROOT/buildproperties.shsource
141+
142+
function remoteURL {
143+
git config remote.origin.url | sed --expression 's,https://github.com/,[email protected]:,'
144+
}
145+
export -f remoteURL
146+
if [ "${BUILD_TYPE}" == "I" ]; then
147+
git push --verbose $(remoteURL) ${AGGREGATOR_LOCAL_BRANCH}
148+
fi
145149
function tagAndPush {
146150
git tag ${BUILD_ID} HEAD
147-
pushURL=$(git config remote.origin.url | sed --expression 's,https://github.com/,[email protected]:,')
148-
git push "${pushURL}" tag ${BUILD_ID}
151+
git push --verbose $(remoteURL) tag ${BUILD_ID}
149152
}
150153
export -f tagAndPush
151154
git submodule foreach 'tagAndPush'

JenkinsJobs/Builds/dockerImages.jenkinsfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ pipeline {
1717
}
1818
stages {
1919
stage('Get Docker Files') {
20+
environment {
21+
GIT_BRANCH = "${scm.branches[0].name}"
22+
GIT_REPOSITORY = "${scm.userRemoteConfigs[0].url}"
23+
}
2024
steps {
2125
cleanWs()
2226
sh '''
23-
git clone --depth=1 -b master https://github.com/eclipse-platform/eclipse.platform.releng.aggregator.git
24-
git clone --depth=1 -b master https://github.com/eclipse-jdt/eclipse.jdt.core
27+
git clone --depth=1 --branch ${GIT_BRANCH} ${GIT_REPOSITORY} eclipse.platform.releng.aggregator
28+
git clone --depth=1 --branch ${GIT_BRANCH} https://github.com/eclipse-jdt/eclipse.jdt.core eclipse.jdt.core
2529
'''
2630
}
2731
}

JenkinsJobs/Releng/prepareNextDevCycle.jenkinsfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,6 @@ pipeline {
286286
}
287287
}
288288
}
289-
replaceInFile('JenkinsJobs/Builds/dockerImages.jenkinsfile', [
290-
'-b master' : "-b ${MAINTENANCE_BRANCH}",
291-
])
292-
replaceInFile('cje-production/buildproperties.txt', [
293-
'BRANCH="master"' : "BRANCH=\"${MAINTENANCE_BRANCH}\"",
294-
])
295289
replaceAllInFile('.gitmodules', [
296290
'branch\\s*=\\s*master' : "branch = ${MAINTENANCE_BRANCH}",
297291
])

cje-production/buildproperties.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# with # are considered comments and no spaces allowed in keys
1818

1919
# CJE build variables
20-
BRANCH="master"
2120
RELEASE_VER="4.38"
2221
STREAM="4.38.0"
2322
STREAMMajor="4"

0 commit comments

Comments
 (0)