molecule 2.0.1
molecule init role -r myrole --ci travis generating a .travis.yml, molecule init role -r myrole --ci circle generating the .circleci/ folder, etc.
Creating a new ansible role to be tested with molecule + travis, I though that I always end up c/c the same .travis.yml from my other roles, here is an example. I also imagin people using CircleCI or other continuous integration. Maybe that'ld be a nice thing for molecule to optionaly generate a working config for CI via that switch.
I don't use circle CI so don't really have much of a reason to implement this. If there is someone in the community that uses circle CI and can provide a generic file as a template, they are free to provide a PR to do so. However, not something I have the bandwidth to take on.
am curious to know if molecule directly support jenkins ? or do need write custom wrapper script ?
@r0ckyte
What do you mean with support Jenkins? You can run molecule with a Jenkins Job.
@dj-wasabi - thanks , i didnt know that its able to run from jenkins. is it like running molecule as script or command in jenkins build stage ?
I use jenkins-pipelines, so I can only show you my Jenkinsfile:
node() {
try {
stage ("Get Latest Code") {
checkout scm
sh 'git rev-parse HEAD > .git/commit-id'
}
stage ("Install Application Dependencies") {
sh 'sudo pip install --upgrade ansible==${ANSIBLE_VERSION} molecule==${MOLECULE_VERSION} docker'
}
stage ("Executing Molecule lint") {
sh 'molecule lint'
}
stage ("Executing Molecule create") {
sh 'molecule create'
}
stage ("Executing Molecule converge") {
sh 'molecule converge'
}
stage ("Executing Molecule idemotence") {
sh 'molecule idempotence'
}
stage ("Executing Molecule verify") {
sh 'molecule verify'
}
stage('Tag git'){
def commit_id = readFile('.git/commit-id').trim()
withEnv(["COMMIT_ID=${commit_id}"]){
sh '''#!/bin/bash
if [[ $(git tag | grep "^${$COMMIT_ID}$" | wc -l) -eq 1 ]]
then echo "Tag already exists"
else echo "Tag will be created"
git config user.name "jenkins"
git config user.email "jenkins@localhost"
git tag -a $COMMIT_ID -m "Added tagging"
git push --tags
fi
'''
}
}
stage('Start Staging Job') {
def commit_id = readFile('.git/commit-id').trim()
withEnv(["COMMIT_ID=${commit_id}"]){
build job: 'ansible-access-2-staging', wait: false, parameters: [string(name: 'COMMIT_ID', value: "${COMMIT_ID}") ]
}
}
} catch(all) {
currentBuild.result = "FAILURE"
throw err
}
}
I seperate the actions into their own stages, so I can easily see when a stage goes into error and if a stage is running slower/faster.
Thanks alot @dj-wasabi
Feel free to open a PR to add documentation around this.
Most helpful comment
Thanks alot @dj-wasabi