Azure Function Deploy with Jenkins

Viewed 869

I created an azure function app with the following command:

az functionapp create --resource-group <resource_name> --consumption-plan-location eastus --name <function_app_name> --storage-account <storage_account> --runtime python --runtime-version 3.7 --functions-version 3 --os-type Linux --deployment-local-git

I'm trying to deploy my functions with the following pipeline script:

node {
   stage('Preparation') { // for display purposes
      // Get some code from a GitHub repository
      git branch: 'master',
      credentialsId:'4222f74d-44c5-4167-99b5-3a61b2d2d1f0',
      url: <github url>

   }
   stage('Publish') {
      azureFunctionAppPublish azureCredentialsId: 'e9ba5433-b5de-4732-ad17-8a517516827d',
                        resourceGroup: < resource_name >, appName: <function_app_name>,
                        filePath: '**/*.py,requirements.txt'

   }
}

But I'm getting this error:

using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress -- https://<function_name>.scm.azurewebsites.net:443/<function_name>.git +refs/heads/*:refs/remotes/origin/* # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.plugins.git.GitException: Command "git fetch --tags --progress -- https://<function_name>.scm.azurewebsites.net:443/<function_name>.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: repository 'https://<function_name>.scm.azurewebsites.net:443/<function_name>.git/' not found

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2044)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:81)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:569)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:798)
    at com.microsoft.jenkins.function.commands.GitDeployCommand.execute(GitDeployCommand.java:84)
    at com.microsoft.jenkins.function.commands.GitDeployCommand.execute(GitDeployCommand.java:53)
    at com.microsoft.jenkins.azurecommons.command.CommandService.runCommand(CommandService.java:88)
    at com.microsoft.jenkins.azurecommons.command.CommandService.execute(CommandService.java:96)
    at com.microsoft.jenkins.azurecommons.command.CommandService.executeCommands(CommandService.java:75)
    at com.microsoft.jenkins.azurecommons.command.BaseCommandContext.executeCommands(BaseCommandContext.java:77)
    at com.microsoft.jenkins.function.FunctionAppDeploymentRecorder.perform(FunctionAppDeploymentRecorder.java:97)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Finished: FAILURE

It seems like the pluging cannot authenticate to my git local repo on Azure.

Any advice?

1 Answers

I was able to reproduce your issue and could see that currently azureFunctionAppPublish plugin doesn't accept / validate Azure Functions that are of Linux OS type. If interested, I would suggest you (the way which worked for me i.e.,) to try the same with Azure Function that is of Windows OS type and it would work. Or as a workaround you may install Azure CLI / Azure PowerShell Jenkins plugin(s) and try command way of deployment as appropriate.

On the other hand, I understand that you may want to use azureFunctionAppPublish plugin and want to deploy under Linux OS type / python runtime only, then in that case I suggest to raise a bug in Jenkins JIRA as mentioned here that's how the maintainers of azureFunctionAppPublish plugin record or work on the bugs and feature requests.

Hope this helps!

Related