forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifests-update.jenkinsFile
64 lines (63 loc) · 2.66 KB
/
manifests-update.jenkinsFile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '7'))
}
agent none
triggers {
cron('H 0 * * *')
}
stages {
stage('Update Manifests') {
agent {
docker {
label 'Jenkins-Agent-AL2023-X64-C54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v3'
args '-e JAVA_HOME=/opt/java/openjdk-11'
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', passwordVariable: 'GITHUB_TOKEN', usernameVariable: 'GITHUB_USER')]) {
try {
sh """
git remote set-url origin https://opensearch-ci:${GITHUB_TOKEN}@github.com/opensearch-project/opensearch-build
git config user.email "[email protected]"
git config user.name "opensearch-ci"
git checkout -b update-manifest
./manifests.sh update
"""
def status = sh(returnStdout: true, script: 'git status --porcelain')
if (status) {
sh """
git add . && git commit -sm "Update manifests"
git push origin update-manifest --force
gh pr create --title '[AUTO] Update input manifests' --body 'I have noticed that a repo has incremented a version. This change updates the corresponding input manifests.' -H update-manifest -B main
"""
} else {
println 'Nothing to commit!'
}
} catch (e) {
error 'An error occured while adding a new manifest!' + e.toString()
}
}
}
}
post() {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}
}