forked from superstreamlabs/memphis.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
64 lines (55 loc) · 2.26 KB
/
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
def gitBranch = env.BRANCH_NAME
def gitURL = "[email protected]:Memphisdev/memphis.py.git"
def repoUrlPrefix = "memphisos"
node ("small-ec2-fleet") {
git credentialsId: 'main-github', url: gitURL, branch: gitBranch
try{
stage('Deploy to pypi') {
sh 'python3 setup.py sdist'
sh 'pip3 install twine'
withCredentials([usernamePassword(credentialsId: 'python_sdk', usernameVariable: 'USR', passwordVariable: 'PSW')]) {
sh '/home/ec2-user/.local/bin/twine upload -u $USR -p $PSW dist/*'
}
}
stage('Checkout to version branch'){
sh """
sudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo yum install gh -y
sed -i -r "s/version=\'[0-9].[0-9].[0-9]/version=\'\$(cat version.conf)/g" setup.py
sed -i -r "s/v[0-9].[0-9].[0-9]/v\$(cat version.conf)/g" setup.py
"""
withCredentials([sshUserPrivateKey(keyFileVariable:'check',credentialsId: 'main-github')]) {
sh """
git reset --hard origin/latest
GIT_SSH_COMMAND='ssh -i $check' git checkout -b \$(cat version.conf)
GIT_SSH_COMMAND='ssh -i $check' git push --set-upstream origin \$(cat version.conf)
"""
}
withCredentials([string(credentialsId: 'gh_token', variable: 'GH_TOKEN')]) {
sh(script:"""gh release create \$(cat version.conf) --generate-notes""", returnStdout: true)
}
}
notifySuccessful()
} catch (e) {
currentBuild.result = "FAILED"
cleanWs()
notifyFailed()
throw e
}
}
def notifySuccessful() {
emailext (
subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
def notifyFailed() {
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}