Reputation: 5
I have 2 different Jenkins pipeline (Say Pipeline1 and Pipeline2) in 2 different Jenkins hosts - Say Host - Jenkins1 and Jenkins2.
Jenkins1 with Pipeline1 has different stages for Deployment in an environment. Jenkins2 with Pipeline2 has the stages for smoke testing for the same environment for different types.
I have taken the urls from Jenkins2 with Pipeline2 and have them ready as below: These are the urls to be triggered after the deployment in Jenkins1 - Pipeline1.
https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=4 https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=5 https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=6 https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=7
So how do I trigger these urls in a stage step in Jenkins1 and Pipeline1 with my credentials?
stages {
stage('Trigger Testing URLs') {
agent { label '' }
steps {
??????HOW To Trigger the above Jenkins URL in this stage???????
}
}
Upvotes: 0
Views: 703
Reputation: 3445
You can simply use curl
to achieve this. Since you already have the URL to call:
curl -X POST -u username:password -g https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=4
Curl is available for both Windows and Linux systems so this should be applicable either way.
stage('Trigger Testing URLs') {
agent { label '' }
steps {
curl -X POST -u username:password -g https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=4
curl -X POST -u username:password -g https://test-jenkins2.com/job/TestRepo/buildWithParameters?token=test&testType=5
...
}
}
Upvotes: 0