Skip to content

Commit

Permalink
Merge pull request #197 from atlassian/jenkins-cd
Browse files Browse the repository at this point in the history
ARC-2282 - added jenkins file
  • Loading branch information
joshkay10 authored Nov 10, 2023
2 parents 7d26938 + 13efabf commit 1f58ace
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions JenkinsFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

pipeline {
agent any
stages {
stage('Trigger Bitbucket Pipeline') {
steps {
script {
echo 'Sending POST request to Bitbucket API'

def bitbucketUrl = 'https://api.bitbucket.org/2.0/repositories/atlassian/jenkins-for-jira-deployment/pipelines/'
def branch = 'main'
def credentialsId = 'jenkins-for-jira-deployment-pipeline-token'

withCredentials([string(credentialsId: 'jenkins-for-jira-deployment-pipeline-token', variable: 'accessToken')]) {
def payload = """
{
"target": {
"type": "pipeline_ref_target",
"ref_name": "${branch}",
"ref_type": "branch",
"selector": {
"type": "custom",
"pattern": "deploy-to-prod"
},
"variables": [
{
"key": "COMMIT_SHA",
"value": "main"
}
]
}
}
"""

sh """
curl --request POST \\
--url '${bitbucketUrl}' \\
--header 'Authorization: Bearer ${accessToken}' \\
--header 'Accept: application/json' \\
--header 'Content-Type: application/json' \\
--data '${payload}'
"""
}
}
}
}
}
}

0 comments on commit 1f58ace

Please sign in to comment.