|
|
@ -1,11 +1,19 @@ |
|
|
|
pipeline { |
|
|
|
agent any |
|
|
|
|
|
|
|
environment { |
|
|
|
GITEA_CREDS = 'test' |
|
|
|
GITEA_REPO_URL = 'https://github.com/mh-lornejad/jenkins-test3.git' |
|
|
|
GITEA_TOKEN = 'your-gitea-token' |
|
|
|
MAIN_BRANCH = 'token' |
|
|
|
} |
|
|
|
|
|
|
|
stages { |
|
|
|
stage('Clone the repo') { |
|
|
|
steps { |
|
|
|
echo "Clone the repo" |
|
|
|
sh "rm -fr jenkins-test3" |
|
|
|
git branch: 'main', credentialsId: 'test', url: 'https://github.com/mh-lornejad/jenkins-test3.git' |
|
|
|
git branch: "${env.MAIN_BRANCH}", credentialsId: "${env.GITEA_CREDS}", url: "${env.GITEA_REPO_URL}" |
|
|
|
} |
|
|
|
} |
|
|
|
stage('Code Analysis') { |
|
|
@ -41,4 +49,32 @@ pipeline { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
post { |
|
|
|
always { |
|
|
|
script { |
|
|
|
def status = currentBuild.result == 'SUCCESS' ? 'success' : 'failure' |
|
|
|
def state = status == 'success' ? 'success' : 'failure' |
|
|
|
def description = "Jenkins build ${status}" |
|
|
|
def commitSha = env.GIT_COMMIT |
|
|
|
|
|
|
|
httpRequest( |
|
|
|
url: "${env.GITEA_REPO_URL}/statuses/${commitSha}", |
|
|
|
httpMode: 'POST', |
|
|
|
customHeaders: [ |
|
|
|
[name: 'Content-Type', value: 'application/json'], |
|
|
|
[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"] |
|
|
|
], |
|
|
|
requestBody: """ |
|
|
|
{ |
|
|
|
"state": "${state}", |
|
|
|
"target_url": "${env.BUILD_URL}", |
|
|
|
"description": "${description}", |
|
|
|
"context": "continuous-integration/jenkins" |
|
|
|
} |
|
|
|
""" |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|