I have a worklow which uses a workflow from another project
include:
- project: {project repo}
ref: {branch name}
file: parent.gitlab-ci.yml
Is there a way to pass a variable to that, similar to how you would pass values to a Github Action? For Example...
include:
- project: {project repo}
ref: {branch name}
file: parent.gitlab-ci.yml
Var1: Foo
Var2: Bar
Thanks,
When a workflow is included, variables are essentially shared with the included workflow. See more here.
Related
I have a MuleSoft application that I am trying to deploy from a pipeline.
I am using a Maven plugin and a connected app for credentials. Plugin configuration looks like this:
<configuration>
<armDeployment>
<muleVersion>${app.runtime}</muleVersion>
<uri>https://anypoint.mulesoft.com</uri>
<businessGroupId>${BUSINESSGROUPID}</businessGroupId>
<target>${TARGET}</target>
<targetType>${TARGETGROUP}</targetType>
<connectedAppClientId>${APPCLIENTID}</connectedAppClientId>
<connectedAppClientSecret>${APPCLIENTSECRET}</connectedAppClientSecret>
<connectedAppGrantType>client_credentials</connectedAppGrantType>
<environment>${ENVIRONMENT}</environment>
</armDeployment>
</configuration>
I define variables in Azure pipeline(3 of them are secret credentials) and when I run the pipeline I am getting 401 Unauthorized error.
When I hard-code values in the above configuration it works fine. Only when I try to have the POM file read them from the pipeline variables do I get this error.
Below is my pipeline config too:
trigger:
- master
variables:
APPCLIENTID: $(APPCLIENTID)
APPCLIENTSECRET: $(APPCLIENTSECRET)
ENVIRONMENT: $(ENVIRONMENT)
BUSINESSGROUPID: $(BUSINESSGROUPID)
TARGET: $(TARGET)
TARGETGROUP: $(TARGETGROUP)
pool:
vmImage: ubuntu-latest
steps:
- task: Maven#3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'clean package deploy -DmuleDeploy'
I am not sure whether I need to define variables here again or not.
How do I make the POM file read variables correctly?
You can't use Azure Pipeline variables directly in the pom. They are not properties in Maven. You have to define them explicitly as such in Maven's command line.
In the goals input you can define Maven properties for the command line and assign them the values from the respective Azure Pipeline variable using the 'goals' input.
I'm guessing that the syntax for referencing variables is $(var) so as an example:
goals: 'clean package deploy -DmuleDeploy -DAPPCLIENTID=$(APPCLIENTID)'
Just try adding the other properties next to APPCLIENTID.
Ok, I found out what the issue is.
Azure Pipelines documentation states that you need to use $() in order to access variables but in the case of a POM file you need to use {}. So the POM file should look like this:
<configuration>
<armDeployment>
<muleVersion>${app.runtime}</muleVersion>
<uri>https://anypoint.mulesoft.com</uri>
<businessGroupId>${BUSINESSGROUPID}</businessGroupId>
<target>${TARGET}</target>
<targetType>${TARGETGROUP}</targetType>
<connectedAppClientId>${APPCLIENTID}</connectedAppClientId>
<connectedAppClientSecret>${APPCLIENTSECRET}</connectedAppClientSecret>
<connectedAppGrantType>client_credentials</connectedAppGrantType>
<environment>${ENVIRONMENT}</environment>
</armDeployment>
</configuration>
One more thing I noticed is that doing this will not allow POM file to read variables set as secret. I am yet to find out how to make this work properly but for now I got most of it to work.
Rest service : http://host:8000/v1/config/resources/removeCollection?put:database=string&put:uris=string*
I want to deploy this REST service extension in MarkLogic using gradle. How can I deploy this?
If you're already using ml-gradle, you can add your implemented interface to marklogic\src\main\ml-modules\services and deploy using the mlLoadModules task. The mlCreateResource task as part of the scaffolding would also add metadata in marklogic\src\main\ml-modules\services\metadata.
I recommend looking at ml-gradle. You can easily hook it up in gradle by adding a few lines, most importantly being:
plugins { id "com.marklogic.ml-gradle" version "4.0.4" }
As described in the readme, you can optionally follow that with invoking the mlNewProject task, which will provide you with a useful scaffold structure for a typical ml-gradle project.
ML-gradle gives you access to all kinds of tasks, including one called mlLoadModules to deploy source, and rest extensions. There is also a built-in task for removing collections in any database, called mlDeleteCollections. You can look at the Task-reference to get a glimpse of all the tasks, or just run gradle tasks.
HTH!
Two easy ways of plugin gradle to invoke REST API:
Method One:
If you don’t have any Project just yet,
create a gradle.properties file in which you define four parameters: host, mlUsername, mlPassword, RestPort
create a build.gradle file in the same folder:
plugins {
id "com.marklogic.ml-gradle" version "4.0.4"
}
task FCdeleteCollections(type: com.marklogic.gradle.task.datamovement.DeleteCollectionsTask) {
………………..
collections = ["{collection-name}"]
}
Invoke the gradle task:
[root# ~] # gradle FCdeleteCollections
Method Two:
If you already scaffolded the Project, in my opinion, it is safer to invoke one-time deletion task like this:
[root# ~] # gradle -Pdatabase={db-name} mlDeleteCollections -Pcollections={collection-name}
My preference is to invoke such task through Java API | DMSDK.
I want to add a subproject to my Gradle project. The project is located somewhere on my hard disk drive, for example:
/A/Path/to/a/ProjectA
/Another/Path/to/another/ProjectB
What I want to achieve is to use ProjectB as a source module within Project A. However, all my attempts to do this so far - either by adding include /Another/Path/to/another/ProjectB or by adding include ':ProjectB'; project(':ProjectB').projectDir = ... in settings.gradle - just failed. Apparently, Gradle is not able to find the project.
How can I add ProjectB as a dependency without moving it from it's location?
Using Gradle 3.4.1, the following works for me (full example here):
include 'app', 'common'
def MY_PATH = '/Users/johndoe/foo'
assert new File("$MY_PATH/random/path/common").exists()
project(':common').projectDir = new File("$MY_PATH/random/path/common")
Thanks for your responses.
Turns out I've made several mistakes:
Adding the project to the built was dependent on the value of an environment variable. I replaced that with a property within gradle.properties.
I tested this by running the settings.gradle usind IntelliJ. I mistakingly expected this to work, but it didn't
I did not add the project as a dependency to the build.gradle file of the parent project.
It works now. Thank you all again!
Is it possible to wrap the call ":myproject:assemble -a" into a task?
I want to provide a one click solution for assembling a single project in a multi project environment. Is that possible?
You can simpy create a custom task and set it's dependsOn property as follows:
assembleMyProject(dependsOn: ':myproject:assemble') {
}
I have a solution containing multiple projects. I can use project variables within Build Events, for example $(TargetDir) to access paths and files of the current project.
Solution 'MyApp'
MyApp
MyApp.Core
MyApp.Setup
I want to add a Pre-Build-Event in MyApp.Setup. The $(TargetDir) would return D:\MyApp\MyApp.Setup\bin\Debug, but I want to gather all files from MyApp-Output Directory and put them into the setup directory.
So is it possible to access variables from other projects within build events?
Something like that:
copy "$(MyApp.TargetDir)\*.*" "$(ProjectDir)\externals"
I propose you build all projects of solution into one folder, and inside that folder create specific project subfolders. For now your projects have TargetDir variable with values:
MyApp - D:\MyApp\MyApp\bin\Debug
MyApp.Core - D:\MyApp\MyApp.Core\bin\Debug
MyApp.Setup - D:\MyApp\MyApp.Setup\bin\Debug
But you can make common target directory, so TargetDir value:
MyApp - D:\MyApp\Debug\MyApp\bin
MyApp.Core - D:\MyApp\Debug\MyApp.Core\bin
MyApp.Setup - D:\MyApp\Debug\MyApp.Setup\bin
And in Pre-Build-Event you can refer to it:
copy "$(TargetDir)\..\MyApp\*.*" "$(ProjectDir)\externals"