-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
53 lines (53 loc) · 1.74 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
pipeline {
agent {
label 'ubuntu-latest'
}
environment {
PACKAGIST_USERNAME = credentials('PACKAGIST_USERNAME')
PACKAGIST_TOKEN = credentials('PACKAGIST_TOKEN')
GITHUB_REPOSITORY = 'your-github-repo-path'
}
stages {
stage('Run Only on Tag') {
when {
expression {
return env.BRANCH_NAME ==~ /^rls_\d+\.\d+\.\d+$/
}
}
steps {
echo "Running on tag: $env.BRANCH_NAME"
}
stages {
stage('Pre-check for Environment Variables') {
steps {
script {
if (!env.PACKAGIST_USERNAME || !env.PACKAGIST_TOKEN) {
error("Error: PACKAGIST_USERNAME or PACKAGIST_TOKEN is not defined")
}
echo "All necessary environment variables are defined."
}
}
}
stage('Checkout Code') {
steps {
checkout scm
}
}
stage('Update Packagist Package') {
steps {
sh '''
curl -XPOST -H 'content-type:application/json' \
"https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_TOKEN}" \
-d '{"repository":{"url":"https://github.com/${GITHUB_REPOSITORY}"}}'
'''
}
}
}
}
}
post {
always {
cleanWs()
}
}
}