Skip to content

Commit 4fd97e0

Browse files
HADOOP-17787. Refactor fetching of credentials in Jenkins (#3167)
1 parent b0b867e commit 4fd97e0

File tree

1 file changed

+25
-40
lines changed

1 file changed

+25
-40
lines changed

dev-support/Jenkinsfile

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
def getGithubAndJiraCreds() {
19+
return [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
20+
passwordVariable: 'GITHUB_TOKEN',
21+
usernameVariable: 'GITHUB_USER'),
22+
usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
23+
passwordVariable: 'JIRA_PASSWORD',
24+
usernameVariable: 'JIRA_USER')]
25+
}
26+
1827
pipeline {
1928

2029
agent {
@@ -103,18 +112,12 @@ pipeline {
103112
}
104113

105114
steps {
106-
withCredentials(
107-
[usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
108-
passwordVariable: 'GITHUB_TOKEN',
109-
usernameVariable: 'GITHUB_USER'),
110-
usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
111-
passwordVariable: 'JIRA_PASSWORD',
112-
usernameVariable: 'JIRA_USER')]) {
113-
sh '''#!/usr/bin/env bash
115+
withCredentials(getGithubAndJiraCreds()) {
116+
sh '''#!/usr/bin/env bash
114117
115-
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
116-
"${SOURCEDIR}/dev-support/jenkins.sh" run_ci
117-
'''
118+
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
119+
"${SOURCEDIR}/dev-support/jenkins.sh" run_ci
120+
'''
118121
}
119122
}
120123

@@ -155,13 +158,7 @@ pipeline {
155158
}
156159

157160
steps {
158-
withCredentials(
159-
[usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
160-
passwordVariable: 'GITHUB_TOKEN',
161-
usernameVariable: 'GITHUB_USER'),
162-
usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
163-
passwordVariable: 'JIRA_PASSWORD',
164-
usernameVariable: 'JIRA_USER')]) {
161+
withCredentials(getGithubAndJiraCreds()) {
165162
sh '''#!/usr/bin/env bash
166163
167164
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
@@ -207,18 +204,12 @@ pipeline {
207204
}
208205

209206
steps {
210-
withCredentials(
211-
[usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
212-
passwordVariable: 'GITHUB_TOKEN',
213-
usernameVariable: 'GITHUB_USER'),
214-
usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
215-
passwordVariable: 'JIRA_PASSWORD',
216-
usernameVariable: 'JIRA_USER')]) {
217-
sh '''#!/usr/bin/env bash
207+
withCredentials(getGithubAndJiraCreds()) {
208+
sh '''#!/usr/bin/env bash
218209
219-
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
220-
"${SOURCEDIR}/dev-support/jenkins.sh" run_ci
221-
'''
210+
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
211+
"${SOURCEDIR}/dev-support/jenkins.sh" run_ci
212+
'''
222213
}
223214
}
224215

@@ -256,18 +247,12 @@ pipeline {
256247
}
257248

258249
steps {
259-
withCredentials(
260-
[usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
261-
passwordVariable: 'GITHUB_TOKEN',
262-
usernameVariable: 'GITHUB_USER'),
263-
usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
264-
passwordVariable: 'JIRA_PASSWORD',
265-
usernameVariable: 'JIRA_USER')]) {
266-
sh '''#!/usr/bin/env bash
250+
withCredentials(getGithubAndJiraCreds()) {
251+
sh '''#!/usr/bin/env bash
267252
268-
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
269-
"${SOURCEDIR}/dev-support/jenkins.sh" run_ci
270-
'''
253+
chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
254+
"${SOURCEDIR}/dev-support/jenkins.sh" run_ci
255+
'''
271256
}
272257
}
273258

0 commit comments

Comments
 (0)