Integrate Azure DevOps to Jenkins - azure

I have set up Jenkins in Azure VM. Now, How can I integrate Azure DevOps Service hook to Jenkins. I want to trigger Jenkins Job when anyone pushes the code in the Azure DevOps repository. I am getting below error "Jenkins query failed with exception 'A connection attempt failed because the connected party did not respond after a period of time Or Established connection failed because connected host has failed to respond'" while setup service hook. I have gone through the "https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/jenkins?view=azure-devops" link but it's not working.

Integrate Azure DevOps to Jenkins
According to the error messages, it shows that Azure devops did not successfully connect Jenkins.
To resolve this issue, just like 4c74356b41 commented, you should make sure you could access the Jenkins from the public internet. You can check following document for some more details:
How to Host Jenkins on Azure
Then you can add Jenkins queue job task in the pipeline, and verify the connection via this task:
Hope this helps.

Related

Provisioning an Azure VM agent using a Jenkins Multipipeline

I have a Jenkins instance running on an AWS EC2. Rather than use the built-in nodes(i have disabled them), I need to provision an Azure VM agent, perform builds and execute tests on that agent. Using the https://plugins.jenkins.io/azure-vm-agents/ via a freestyle job I was able to successfully provision an Azure VM agent on demand. However I an unable to achieve the same via a Multibranch pipeline ( there is a seperate repo for Jenkins File and one for the code repo) (plugin https://plugins.jenkins.io/remote-file/). It does not seem to kick of the Azure VM agent and fails waiting for an agent. If i enable the built-in node, it works. So it appears that via the pipeline the azure-vm-agents is not triggering for provisioning. . There appears as if a link For how to select agent in pipeline, refer to this doc. within the https://plugins.jenkins.io/azure-vm-agents/ page does not lead anywhere. Any thoughts much appreciated.

Package deployment using ZIP Deploy failed with Azure DevOps Pipeline

I am trying to deploy an application to windows based App Service in Azure using Azure DevOps Pipeline. For the first time, I don't see any issues and deployment got successful. But the next time, it got failed. I am getting the below error.
Failed to deploy web package to App Service.
To debug further please check Kudu stack trace URL : https://$XYZ-dev:***#XYZ-dev.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace
Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
When I go to the App Service in Azure Portal and from Deployment Center if I disconnect and trigger the pipeline, it get successful. But again next time it got failed.
Please anyone let us know the fix for this issue.
Thanks.

Integrating Local Jenkins Setup with Azure Dev OPS

I wanted to know if there is any good documentation available for the below scenario
I have a jenkins master running on my laptop
This jenkins master have several jobs which executes locally
I now want to call these jobs from Azure Dev Ops. Meaning a Devops job from Azure cloud should trigger a build on my local Jenkins setup
I saw several videos but I am finding it difficult to get around it.
Is there any easier way by just making use of a plugin to connect and executing the job?
I did saw some Udemy videos but then those involve a lot of setting to be done and does expose your system to outside vulnarabilities as firewalls and router settings are played on with.
Any help would be appreciated. Thanks!
You can enable Trigger builds remotely for your jenkins jobs, and then use a script task in the azure devops pipeline to trigger your jenkins pipeline. See below steps:
1, Firstly you need to create a self-hosted agent on your local jenkins server machine. Since the jenkins server is running locally, you need a local agent to communicate with your local jenkins server. Follow the steps here to create your local hosted agent.
2, Enable Trigger builds remotely on Jenkins
Go the the Build Triggers Tab of your jenkins pipeline configure page--> Then check Trigger builds remotely--> Specify a Token (will be used in the URL)
3, Define a secret variable to host your jenkins password in azure devops pipeline:
4, Add a bash task in your azure devops pipeline to run the below curl command:
#token must be the same with the token you entered in above step
curl -u $(username):$(password) http://localhost:8080/job/myproject/build?token=anytoken
See this thread trigger jenkins job via curl command remotely for more information.
5, Targeting your self-hosted agent pool to run your azure devops pipeline on self-hosted agent.
Then your local jenkin jobs will be triggered by the azure devops jobs.
Update:
You can also use Jenkins queue job task to queue a jenkin job in azure devops pipeline. See below steps:
1, Create a API Token in your Jenkin server.
Go your jenkin account configure page. To create a API token.
2, Add Jenkins queue job task in azure devops pipeline.
3, Click the Manage link to create a jenkins service connection--> In the newly opened page-->Create Service connection-->Select Jenkins--> Next
Enter the required information as below screenshot. Note: username is your user account for jenkin server, the Password is the API Token You generated in above step.
4, Configure your Jenkin queue job task as below

Can MSFT Azure pipeline connect to Bitbucket as source control system then build and deploy the build artifacts to on-premise server?

I've gotten the capability about "deploy the build artifacts to on-premise server". But I am not sure if Azure pipeline can connect to Bitbucket to fetch the code then do the build.
Yes, try to add a new service connection and grant permission for your pipelines.
Here is how you can connect it:
From this point, you should be able to create your pipelines from the code on bitbucket.

Unable to disconnect continous deployment for Azure function

I have setup continuous deployment for my Azure function via App Service's deployment center. I linked the same to my Azure DevOps account and any commit made against code to my source control repository triggers an auto deployment to Azure. While this is working fine, when I now try to disconnect this auto deployment setup, Azure throws the below error:
I have already tried stopping the function and then trying to disconnect but that too hasn't helped.

Resources