I am trying to use Azuresigntool within the pom.xml file. Then I want to run this on Jenkins so all the exe files are signed when the release package is created. I took the code from Gemini AI. It is suggesting to use azure-maven-plugin for the artifact id. The version for this i.e. 2.14.0, I am taking this number from Maven Central. When I try to run it on Jenkins, it gives me an error saying,
[ERROR] Plugin com.microsoft.azure:azure-maven-plugin:2.14.0 or one of its dependencies could not be resolved: Could not find artifact com.microsoft.azure:azure-maven-plugin:jar:2.14.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
Please help.
Here is the code from Pom.xml
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-maven-plugin</artifactId>
<version>2.14.0</version>
<executions>
<execution>
<id>sign</id>
<phase>package</phase>
<goals>
<goal>azuresign</goal>
</goals>
<configuration>
<workingDirectory>${project.build.directory}/Release</workingDirectory>
<executable>${jenkins.jenkinsExecutable}/azuresigntools.exe</executable>
<arguments>
<argument>sign</argument>
<argument>-kvu</argument>
<argument>${jenkins.jenkinsAzureCertificateURL}</argument>
<argument>-kvt</argument>
<argument>${jenkins.jenkinsAzureTenantId}</argument>
<argument>kvi</argument>
<argument>${jenkins.jenkinsAzureClientId}</argument>
<argument>-kvs</argument>
<argument>${jenkins.jenkinsAzureClientSecret}</argument>
<argument>-kvc</argument>
<argument>${jenkins.jenkinsAzureCertificateName}</argument>
<argument>-tr</argument>
<argument>${jenkins.jenkinsAzureTimeStamp}</argument>
<argument>-td</argument>
<argument>sha256</argument>
<argument>-td</argument>
<argument>sha256</argument>
<argument>-v</argument>
<argument>${project.build.directory}/Release</argument>
<argument>
<filesets>
<fileset>
<directory>${project.build.directory}/Release</directory>
<includes>
<include>*.exe</include>
</includes>
</fileset>
</filesets>
</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</build>
<properties>
<jenkins.jenkinsExecutable>${env.AZURESIGNTOOLS_FULLPATH}</jenkins.jenkinsExecutable>
<jenkins.jenkinsAzureCertificateURL>${env.AZURE_KV_URL}</jenkins.jenkinsAzureCertificateURL>
<jenkins.jenkinsAzureCertificateName>${env.AZURE_CERT_NAME}</jenkins.jenkinsAzureCertificateName>
<jenkins.jenkinsAzureTenantId>${env.AZURE_TENANT_ID}</jenkins.jenkinsAzureTenantId>
<jenkins.jenkinsAzureClientId>${env.AZURE_CLIENT_ID}</jenkins.jenkinsAzureClientId>
<jenkins.jenkinsAzureClientSecret>${env.AZURE_CLIENT_SECRET}</jenkins.jenkinsAzureClientSecret>
<jenkins.jenkinsAzureTimeStamp>{env.TIME_STAMP}</jenkins.jenkinsAzureTimeStamp>
</properties>
In the jenkins file, all these environment variables are defined.
The error is happening because the plugin you are using azure-maven-plugin
is not meant for signing .exe
files. That plugin is mainly used for deploying Azure services like web apps or functions, and it doesn’t have a goal called azuresign
.
Instead of signing the .exe
files during the Maven build, you can use the exec-maven-plugin
. This lets Maven run any external command, like azuresigntool.exe
.
pom.xml :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-executables</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${jenkins.jenkinsExecutable}</executable>
<workingDirectory>${project.build.directory}/Release</workingDirectory>
<arguments>
<argument>sign</argument>
<argument>-kvu</argument>
<argument>${jenkins.jenkinsAzureCertificateURL}</argument>
<argument>-kvt</argument>
<argument>${jenkins.jenkinsAzureTenantId}</argument>
<argument>-kvi</argument>
<argument>${jenkins.jenkinsAzureClientId}</argument>
<argument>-kvs</argument>
<argument>${jenkins.jenkinsAzureClientSecret}</argument>
<argument>-kvc</argument>
<argument>${jenkins.jenkinsAzureCertificateName}</argument>
<argument>-tr</argument>
<argument>${jenkins.jenkinsAzureTimeStamp}</argument>
<argument>-td</argument>
<argument>sha256</argument>
<argument>${project.build.directory}/Release/yourapp.exe</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Check to replace appname.exe
with the actual name of the file you are signing. And if you need to sign multiple .exe
files at once.