Trying to incorporate SaltStack Plugin(https://plugins.jenkins.io/saltstack/) in a pipeline
Plugin is used to send a message to Salt API as a part of the Build step,
sample DSL Pipeline script is below
pipeline {
agent {
node {
label 'agent1'
}
}
stages {
stage('saltcommand') {
steps {
salt(authtype: 'pam', clientInterface: local(arguments: '"sleep 3; ls -la"', blockbuild: true, function: 'cmd.run', jobPollTime: 6, target: '*', targettype: 'glob'), credentialsId: 'b5f40401-01b9-4b27-a4e8-8ae94bc90250', saveFile: true, servername: 'http://master.local:8000')
script {
env.WORKSPACE = pwd()
def output = readFile "${env.WORKSPACE}/saltOutput.json"
echo output
}
}
}
}
}
Could anyone from the community please answer how to generate credentialsId argument for the salt command under stages/stage/steps salt(), did not find anything regarding this from official Salt(https://docs.saltstack.com/en/latest/) or Jenkins(https://jenkins.io/doc/)?
The credentialsId
refers to the credentials stored in Jenkins. As you are using the pam
authentication type this will need to be an username and password allowed to access to Salt API.
The Jenkins documention gives you a detailed description on how to add global credentials. The credentialsId
is the in the ID field.
Note: By default the Salt API isn't enabled and requires additional configuration on the SaltStack side, see the Jenkins SalstStack plugin or SaltStack documentation for more information.